summaryrefslogtreecommitdiffstats
path: root/fish_show.py
diff options
context:
space:
mode:
Diffstat (limited to 'fish_show.py')
-rw-r--r--fish_show.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/fish_show.py b/fish_show.py
index cb80d55..e410895 100644
--- a/fish_show.py
+++ b/fish_show.py
@@ -11,6 +11,7 @@ from fish_types import Fish
class Light(object):
"""Represent a bridge light and its state."""
+ __slots__=('light', 'color', 'transitioning_to', 'x', 'y', 'step')
def __init__(self, x, y, light):
"""Store all facts about a light."""
self.light = light
@@ -34,8 +35,9 @@ class Light(object):
new_color = new_background
for fish in fishes:
coverage = compute_coverage(fish, self.x, self.y)
- fish_color = fish.color_at(self.x, self.y)
- new_color = coverage * fish_color + (1 - coverage) * new_color
+ if coverage > 0.01:
+ fish_color = fish.color_at(self.x, self.y)
+ new_color = coverage * fish_color + (1 - coverage) * new_color
self.light.setRGBRaw(
*map(lambda x: clamp(0, x, 1), new_color.components)
)