# 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.hue import hsvToRgb
from random import random
from math import sin, pi
        self.usecount = []
        self.blocksize = int(matrix.numpix/(self.huecount-1))

        self.hues = []
        for hue in range(0, self.huecount):
            self.hues.append(random())

        self.sinlut = []
        for i in range(0, self.blocksize):
            s = sin(pi*i/(self.blocksize-1))
            self.sinlut.append(s*s*s)

    def start(self, matrix):
        pass

    def _color(self):
        self.offset += 1

        if self.contiguous:
            hue = 0.0 + (self.offset+2*self.base) % 256
            return hsvToRgb(hue/255)

        index = ((self.base+self.offset)/self.blocksize) % self.huecount
        hue = self.hues[int(index)]

        phase = (self.base+self.offset) % self.blocksize
        value = self.sinlut[phase]

        self.usecount[int(index)] += 1


# 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/baseclasses/flow.py
from .. _baseclass import ArtBaseClass
from opc.hue import hsvToRgb
from random import random
from math import sin, pi

        self.usecount = []
        self.blocksize = int(matrix.numpix/(self.huecount-1))

        self.hues = []
        for hue in range(0, self.huecount):
            self.hues.append(random())

        self.sinlut = []
        for i in range(0, self.blocksize):
            s = sin(pi*i/(self.blocksize-1))
            self.sinlut.append(s*s*s)

    def start(self, matrix):
        pass

    def _color(self):
        self.offset += 1

        if self.contiguous:
            hue = 0.0 + (self.offset+2*self.base) % 256
            return hsvToRgb(hue/255)

        index = ((self.base+self.offset)/self.blocksize) % self.huecount
        hue = self.hues[int(index)]

        phase = (self.base+self.offset) % self.blocksize
        value = self.sinlut[phase]

        self.usecount[int(index)] += 1


        return hsvToRgb(hue, 1, value)