summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fish_render.py29
1 files changed, 29 insertions, 0 deletions
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)