# 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 math import sin, cos, fmod, pi




class Art(ArtBaseClass):

    description = "Radar-like, but without the enemy planes"

    def __init__(self, matrix, config):
        self.angle = 0.0
        self.hue = 0
        self.astep = pi/48
        self.hstep = pi/1024

        self.radius = min(matrix.width, matrix.height)/2.2
        self.x0 = matrix.width/2
        self.y0 = matrix.height/2

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

    def refresh(self, matrix):
        matrix.fade(0.995)

        y0 = matrix.height/2
        x0 = matrix.width/2

        if self.angle >= pi:
            x0 -= 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/rotor.py
from ._baseclass import ArtBaseClass
from opc.hue import hsvToRgb
from math import sin, cos, fmod, pi





class Art(ArtBaseClass):

    description = "Radar-like, but without the enemy planes"

    def __init__(self, matrix, config):
        self.angle = 0.0
        self.hue = 0
        self.astep = pi/48
        self.hstep = pi/1024

        self.radius = min(matrix.width, matrix.height)/2.2
        self.x0 = matrix.width/2
        self.y0 = matrix.height/2

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

    def refresh(self, matrix):
        matrix.fade(0.995)

        y0 = matrix.height/2
        x0 = matrix.width/2

        if self.angle >= pi:
            x0 -= 1


        if self.angle > (0.5*pi) and self.angle < (1.5*pi):