# Path: opc/hue.py
# @mwt(timeout=20)
# @timefunc
# def hsvToRgb(h, s=1.0, v=1.0, rainbow=True):
#     """
#     Convert a (h, s, v) value to the (r, g, b) color space. By default,
#     we use a more cpu-intense method to curve the hue ramps above the
#     typical linear, with a view to evening out the visible range of yellow,
#     cyan, and purple.
# 
#     This method takes h, s, and v values in range 0..1 and returns r, g,
#     and b values in range 0..255.
#     """
#     if rainbow:
#         return [sin(c*pi/2)*255 for c in colorsys.hsv_to_rgb(h, s, v)]
# 
#     return [c*255 for c in colorsys.hsv_to_rgb(h, s, v)]


from ._baseclass import ArtBaseClass
from opc.colors import BLACK
from opc.hue import hsvToRgb
from math import fmod, sin, cos, sqrt
import numpy as np
        self.amp = 0
        self.mult = 1+sqrt(matrix.numpix/32)/90
        self.train = ClearTrain(TRAIN_LEN)

    def start(self, matrix):
        matrix.clear()

    def refresh(self, matrix):
        # this relies on the fact that the pixels we seed get multiplied and
        # overfow the uint8 in intresting ways
        matrix.blur(3)
        matrix.buf.buf = (self.mult*matrix.buf.buf).astype(np.uint8)

        self.amp += DELTA_AMP
        if self.amp >= 1 and False:
            self.amp = 0

        self.hue += DELTA_HUE

        self.ang += DELTA_ANG

        xcenter = matrix.width / 2.0
        ycenter = matrix.height / 2.0
        amp = sin(self.amp)

        tx = amp * sin(self.ang)
        ty = amp * cos(self.ang)

        x = xcenter + xcenter * tx
        y = ycenter + ycenter * ty

# Path: opc/hue.py
# @mwt(timeout=20)
# @timefunc
# def hsvToRgb(h, s=1.0, v=1.0, rainbow=True):
#     """
#     Convert a (h, s, v) value to the (r, g, b) color space. By default,
#     we use a more cpu-intense method to curve the hue ramps above the
#     typical linear, with a view to evening out the visible range of yellow,
#     cyan, and purple.
# 
#     This method takes h, s, and v values in range 0..1 and returns r, g,
#     and b values in range 0..255.
#     """
#     if rainbow:
#         return [sin(c*pi/2)*255 for c in colorsys.hsv_to_rgb(h, s, v)]
# 
#     return [c*255 for c in colorsys.hsv_to_rgb(h, s, v)]


# Path: art/cascade.py
from ._baseclass import ArtBaseClass
from opc.colors import BLACK
from opc.hue import hsvToRgb
from math import fmod, sin, cos, sqrt
import numpy as np

        self.amp = 0
        self.mult = 1+sqrt(matrix.numpix/32)/90
        self.train = ClearTrain(TRAIN_LEN)

    def start(self, matrix):
        matrix.clear()

    def refresh(self, matrix):
        # this relies on the fact that the pixels we seed get multiplied and
        # overfow the uint8 in intresting ways
        matrix.blur(3)
        matrix.buf.buf = (self.mult*matrix.buf.buf).astype(np.uint8)

        self.amp += DELTA_AMP
        if self.amp >= 1 and False:
            self.amp = 0

        self.hue += DELTA_HUE

        self.ang += DELTA_ANG

        xcenter = matrix.width / 2.0
        ycenter = matrix.height / 2.0
        amp = sin(self.amp)

        tx = amp * sin(self.ang)
        ty = amp * cos(self.ang)

        x = xcenter + xcenter * tx
        y = ycenter + ycenter * ty

        color = hsvToRgb(fmod(self.hue, 1), 1, 1)