# 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, randrange




class Rectangle(object):

    def __init__(self, matrix):
        self.value = 0.0
        self.hue = random()

        self.x = randrange(0, matrix.width)
        self.y = randrange(0, matrix.height)
        self.w = randrange(int(matrix.width/8), int(matrix.width/2))
        self.h = randrange(int(matrix.height/8), int(matrix.height/2))

    def update(self, matrix):
        self.value += 0.2

        matrix.fillRect(
            self.x, self.y,
            self.w, self.h,

# 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/block.py
from ._baseclass import ArtBaseClass
from opc.hue import hsvToRgb
from random import random, randrange





class Rectangle(object):

    def __init__(self, matrix):
        self.value = 0.0
        self.hue = random()

        self.x = randrange(0, matrix.width)
        self.y = randrange(0, matrix.height)
        self.w = randrange(int(matrix.width/8), int(matrix.width/2))
        self.h = randrange(int(matrix.height/8), int(matrix.height/2))

    def update(self, matrix):
        self.value += 0.2

        matrix.fillRect(
            self.x, self.y,
            self.w, self.h,

            hsvToRgb(h=self.hue, v=self.value),