# 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.head = (self.head + 1) % self.length


DELTA_AMP = 0.09
DELTA_ANG = 0.033
DELTA_HUE = 0.006
TRAIN_LEN = 16


class Art(ArtBaseClass):

    description = "Color cascade (needs tuning for > 32x32)"

    def __init__(self, matrix, config):
        self.hue = 0
        self.ang = 0
        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)


# 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.head = (self.head + 1) % self.length


DELTA_AMP = 0.09
DELTA_ANG = 0.033
DELTA_HUE = 0.006
TRAIN_LEN = 16


class Art(ArtBaseClass):

    description = "Color cascade (needs tuning for > 32x32)"

    def __init__(self, matrix, config):
        self.hue = 0
        self.ang = 0
        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