# Path: uchroma/renderer.py
# MAX_FPS = 30
# DEFAULT_FPS = 15
# NUM_BUFFERS = 2
# class Renderer(HasTraits, object):
#     def __init__(self, driver, *args, **kwargs):
#     def _z_changed(self, change):
#     def init(self, frame) -> bool:
#     def finish(self, frame ):
#     async def draw(self, layer: Layer, timestamp: float) -> bool:
#     def has_key_input(self) -> bool:
#     def key_expire_time(self) -> float:
#     def key_expire_time(self, expire_time: float):
#     async def get_input_events(self):
#     def _fps_changed(self, change):
#     def logger(self):
#     def _free_layer(self, layer):
#     async def _run(self):
#     def _flush(self):
#     async def _stop(self):


import asyncio
from traitlets import Int, observe
from grapefruit import Color
from uchroma.renderer import Renderer, RendererMeta

DEFAULT_SPEED = 8


class Rainbow(Renderer):

    # meta
    meta = RendererMeta('Rainflow', 'Simple flowing colors', 'Stefanie Kondik', '1.0')

    # configurable traits
    speed = Int(default_value=DEFAULT_SPEED, min=0, max=20).tag(config=True)
    stagger = Int(default_value=4, min=0, max=100).tag(config=True)


    def __init__(self, *args, **kwargs):
        super(Rainbow, self).__init__(*args, **kwargs)

        self._gradient = None
        self._offset = 0

        self.fps = 5


    @staticmethod
    def _hue_gradient(start, length):
        step = 360 / length
        return [Color.NewFromHsv((start + (step * x)) % 360, 1, 1) for x in range(0, length)]


    @observe('speed', 'stagger')

# Path: uchroma/renderer.py
# MAX_FPS = 30
# DEFAULT_FPS = 15
# NUM_BUFFERS = 2
# class Renderer(HasTraits, object):
#     def __init__(self, driver, *args, **kwargs):
#     def _z_changed(self, change):
#     def init(self, frame) -> bool:
#     def finish(self, frame ):
#     async def draw(self, layer: Layer, timestamp: float) -> bool:
#     def has_key_input(self) -> bool:
#     def key_expire_time(self) -> float:
#     def key_expire_time(self, expire_time: float):
#     async def get_input_events(self):
#     def _fps_changed(self, change):
#     def logger(self):
#     def _free_layer(self, layer):
#     async def _run(self):
#     def _flush(self):
#     async def _stop(self):


# Path: uchroma/fxlib/rainbow.py
import asyncio
from traitlets import Int, observe
from grapefruit import Color
from uchroma.renderer import Renderer, RendererMeta


DEFAULT_SPEED = 8


class Rainbow(Renderer):

    # meta
    meta = RendererMeta('Rainflow', 'Simple flowing colors', 'Stefanie Kondik', '1.0')

    # configurable traits
    speed = Int(default_value=DEFAULT_SPEED, min=0, max=20).tag(config=True)
    stagger = Int(default_value=4, min=0, max=100).tag(config=True)


    def __init__(self, *args, **kwargs):
        super(Rainbow, self).__init__(*args, **kwargs)

        self._gradient = None
        self._offset = 0

        self.fps = 5


    @staticmethod
    def _hue_gradient(start, length):
        step = 360 / length
        return [Color.NewFromHsv((start + (step * x)) % 360, 1, 1) for x in range(0, length)]


    @observe('speed', 'stagger')

    def _create_gradient(self, change=None):