# Path: opc/hue.py
# def getColorGen(step=0.05, hue=0, sat=1, val=1):
#     """
#     Generator that returns a stream of shades as colors
#     """
#     hue = getHueGen(step, hue)
#     while True:
#         yield hsvToRgb(next(hue), sat, val)


from ._baseclass import ArtBaseClass
from opc.hue import getColorGen
from math import sin, cos, pi
from .utils.frange import frange

class Art(ArtBaseClass):

    description = "Lissajous figures"

    def __init__(self, matrix, config):
        self.color = getColorGen(0.01)
        self.phase_z = 0

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

    def refresh(self, matrix):
        matrix.shift(.9, 1, .9)
        self.phase_z += DELTA_Z

        color = next(self.color)
        xcenter = matrix.width/2.0
        ycenter = matrix.height/2.0
        theta = sin(self.phase_z)
        if theta < 0:
            theta_x, theta_y = 1, 1 - 2*theta
        else:
            theta_x, theta_y = 1 + 2*theta, 1

        count = 0
        step = 2*pi / (matrix.numpix/6)
        for angle in frange(0, 2*pi, step):
            x = int(xcenter + xcenter * sin(theta_x * angle))
            y = int(ycenter + ycenter * cos(theta_y * angle))

# Path: opc/hue.py
# def getColorGen(step=0.05, hue=0, sat=1, val=1):
#     """
#     Generator that returns a stream of shades as colors
#     """
#     hue = getHueGen(step, hue)
#     while True:
#         yield hsvToRgb(next(hue), sat, val)


# Path: art/lissajous.py
from ._baseclass import ArtBaseClass
from opc.hue import getColorGen
from math import sin, cos, pi
from .utils.frange import frange


class Art(ArtBaseClass):

    description = "Lissajous figures"

    def __init__(self, matrix, config):
        self.color = getColorGen(0.01)
        self.phase_z = 0

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

    def refresh(self, matrix):
        matrix.shift(.9, 1, .9)
        self.phase_z += DELTA_Z

        color = next(self.color)
        xcenter = matrix.width/2.0
        ycenter = matrix.height/2.0
        theta = sin(self.phase_z)
        if theta < 0:
            theta_x, theta_y = 1, 1 - 2*theta
        else:
            theta_x, theta_y = 1 + 2*theta, 1

        count = 0
        step = 2*pi / (matrix.numpix/6)
        for angle in frange(0, 2*pi, step):
            x = int(xcenter + xcenter * sin(theta_x * angle))
            y = int(ycenter + ycenter * cos(theta_y * angle))

            if count == 0: