From cc3d2cd333f6c0c18a201d4ede36b1c62e9caef8 Mon Sep 17 00:00:00 2001 From: group1 Date: Thu, 13 Oct 2016 23:51:42 -0400 Subject: Package include path fix and add optimization for computing coverage --- fish_show.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'fish_show.py') diff --git a/fish_show.py b/fish_show.py index 6677ddd..84b0516 100644 --- a/fish_show.py +++ b/fish_show.py @@ -89,6 +89,7 @@ class Fish(object): 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 @@ -112,7 +113,8 @@ class Light(object): new_color = new_background for fish in fishes: coverage = compute_coverage(fish, self.x, self.y) - new_color = coverage * fish.color + (1 - coverage) * new_color + if coverage > 0.01: + new_color = coverage * fish.color + (1 - coverage) * new_color self.light.setRGBRaw( *map(lambda x: clamp(0, x, 1), new_color.components) ) -- cgit v1.3.1