# Path: opc/matrix/hq.py
# class HQ(object):
# 
#     """
#     use the HQ class to savely wrap art init blocks when you need to
#     switch on HQ for set-up purposes. For example:
# 
#         from opc.matrix import HQ
# 
# 
#         class Art(object):
# 
#             def __init__(self, matrix):
# 
#                 with HQ(matrix):
#                     initialization stuff...
#     """
# 
#     def __init__(self, matrix):
#         self.matrix = matrix
# 
#     def __enter__(self):
#         self.matrix.hq()
# 
#     def __exit__(self, type, value, traceback):
#         self.matrix.hq(False)


from ._baseclass import ArtBaseClass
from random import random, randrange
from math import sqrt
from .utils.pen import Pen
from opc.matrix import HQ




class Art(ArtBaseClass):

    description = "Rain falling down the display"

    def __init__(self, matrix, config):
        with HQ(matrix):
            hue = random()
            pencount = int(sqrt(matrix.width*matrix.height/2))

            self.pens = []
            for pen in range(pencount):
                speed = float(2*pen)/pencount

                # height is longer than the height of the screen, so drops stay
                # off screen for a little while
                height = int(matrix.height*1.1)

                pen = Pen(
                    matrix.width, height,
                    randrange(matrix.width), height,
                    0, -speed,
                    hue=hue,
                    radius=4,

# Path: opc/matrix/hq.py
# class HQ(object):
# 
#     """
#     use the HQ class to savely wrap art init blocks when you need to
#     switch on HQ for set-up purposes. For example:
# 
#         from opc.matrix import HQ
# 
# 
#         class Art(object):
# 
#             def __init__(self, matrix):
# 
#                 with HQ(matrix):
#                     initialization stuff...
#     """
# 
#     def __init__(self, matrix):
#         self.matrix = matrix
# 
#     def __enter__(self):
#         self.matrix.hq()
# 
#     def __exit__(self, type, value, traceback):
#         self.matrix.hq(False)


# Path: art/rain.py
from ._baseclass import ArtBaseClass
from random import random, randrange
from math import sqrt
from .utils.pen import Pen
from opc.matrix import HQ





class Art(ArtBaseClass):

    description = "Rain falling down the display"

    def __init__(self, matrix, config):
        with HQ(matrix):
            hue = random()
            pencount = int(sqrt(matrix.width*matrix.height/2))

            self.pens = []
            for pen in range(pencount):
                speed = float(2*pen)/pencount

                # height is longer than the height of the screen, so drops stay
                # off screen for a little while
                height = int(matrix.height*1.1)

                pen = Pen(
                    matrix.width, height,
                    randrange(matrix.width), height,
                    0, -speed,
                    hue=hue,
                    radius=4,

                    persist=False)