From 78fde3bb014ecd8e2368f2cc088839aecd0ca1ed Mon Sep 17 00:00:00 2001 From: group1 Date: Tue, 27 Sep 2016 17:50:28 -0400 Subject: Fish render --- fish_render.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 fish_render.py diff --git a/fish_render.py b/fish_render.py new file mode 100644 index 0000000..be94a23 --- /dev/null +++ b/fish_render.py @@ -0,0 +1,29 @@ + +class Fish(object): + def __init__(self, x, y, width, height, color): + self.x = x + self.y = y + self.width = width + self.height = height + self.color = color + + +class BridgeRender(object): + WIDTH_SEGMENTS = 200 + HEIGHT_SEGMENTS = 2 + SAMPLES_PER_SEGMENT = 4 # Actual samples is this squared + + def __init__(self, fish): + self.fish = fish + + def compute_coverage(self, x, y): + min_x = max(x, self.fish.x - self.fish.width) + max_x = min(x+1, self.fish.x + self.fish.width) + min_y = max(y, self.fish.y - self.fish.height) + max_y = min(y+1, self.fish.y + self.fish.height) + + return (max_x - min_x) * (max_y - min_y) + + def compute_color(self, x, y, base_color): + cov = compute_coverage(x, y) + return (cov * self.fish.color) + ((1 - cov) * base_color) -- cgit v1.3.1