diff options
Diffstat (limited to 'fish_show.py')
| -rw-r--r-- | fish_show.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/fish_show.py b/fish_show.py index e4f24dd..51693e4 100644 --- a/fish_show.py +++ b/fish_show.py @@ -78,7 +78,7 @@ class Light(object): self.x = x self.y = y - def update(self, fish): + def update(self, fishes): """Change color depending on where the fish is.""" if abs(self.transitioning_to - self.color) <= self.step: self.transitioning_to = pick_HSV().to_RGB() @@ -87,14 +87,12 @@ class Light(object): new_background = transition( self.color, self.transitioning_to, self.step ) - coverage = compute_coverage(fish, self.x, self.y) - #coverage *= coverage - new_color = coverage * fish.color + (1 - coverage) * new_background - #new_color = new_background + self.color = new_background - if self.x == 30 and self.y == 0: - pass - #print(self.color.r(), self.color.g(), self.color.b()) + 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 self.light.setRGBRaw( *map(lambda x: clamp(0, x, 1), new_color.components) ) @@ -149,13 +147,14 @@ class FishShow(Show): for x in xrange(self.bridge.WIDTH)] random_hue = random.random() fish_color = color.HSV(random_hue, 1, 20/100).to_RGB() - self.fish = Fish(0, 0.5, 23, 1.5, fish_color, 1) + self.fishes = [Fish(0, 0.5, 23, 1.5, fish_color, 1), Fish(100, 0.5, 23, 1.5, fish_color, 1)] def update(self): - self.fish.update() + for fish in self.fishes: + fish.update() for light in self.lights: - light.update(self.fish) + light.update(self.fishes) def rand_in_range(low, high): return random.random() * (high - low) + low |
