move rainbow generation to lights
so we can support lights with multiple pixels properly
This commit is contained in:
parent
ca5991da50
commit
85c3c1b8e3
2 changed files with 26 additions and 18 deletions
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
from colorsys import hsv_to_rgb
|
||||
|
||||
LOG = logging.getLogger('DMX')
|
||||
|
||||
|
@ -22,3 +23,21 @@ class BaseDMXLight:
|
|||
ret = self._dump()
|
||||
LOG.debug(f'{str(self)} -> {ret[1]}')
|
||||
return ret
|
||||
|
||||
def rainbow(self, idx, angle, number_of_lights, intensity, brightness):
|
||||
my_degrees_dec = (
|
||||
(angle + (idx * (360 / number_of_lights))) % 360 / 360
|
||||
)
|
||||
r, g, b = hsv_to_rgb(
|
||||
my_degrees_dec,
|
||||
1,
|
||||
intensity / 100,
|
||||
)
|
||||
|
||||
self.red = int(r * 255)
|
||||
self.green = int(g * 255)
|
||||
self.blue = int(b * 255)
|
||||
self.white = 0
|
||||
self.intensity = brightness
|
||||
|
||||
return self.dump()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue