Ejemplo n.º 1
0
def random_color(hue=None, luminosity=None):
    """
    Return a random color, by default a bright and highly
    saturated color.

    'hue' can be: 'red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink', 'monochrome'
    'luminosity' can be: 'bright', 'light', 'dark', 'random'
    """
    h = pick_hue(hue)
    s = pick_saturation(h, hue, luminosity)
    v = pick_brightness(h, s, luminosity)

    h = h / 360
    s = s / 100
    v = v / 100

    return HSV(h, s, v)
Ejemplo n.º 2
0
def color_transition(start_color, end_color, steps=20):
    """    
    Takes two Color objects and produce a sequence of colors that
    transition between them.  `steps` specifies the number of
    intermediate steps in the sequence.
    """
    assert isinstance(start_color,
                      Color), "start_color must be a Color instance"
    assert isinstance(end_color, Color), "end_color must be a Color instance"

    h1, s1, v1 = start_color.hsv
    h2, s2, v2 = end_color.hsv

    h_seq = hsv_transition(h1, h2, steps, wrap=True)
    s_seq = hsv_transition(s1, s2, steps)
    v_seq = hsv_transition(v1, v2, steps)

    for (h, s, v) in itertools.izip(h_seq, s_seq, v_seq):
        yield HSV(h % 1, s, v)
Ejemplo n.º 3
0
class PinsAndStripes(object):
    def __init__(self, sheep_sides):
        self.name = "Pinwheel"
        self.sheep = sheep_sides.both
        self.speed = 0.08
        self.color = HSV(0.66, 0.7, 0.9)

    def next_frame(self):
        current_cell = 0
        end_color = self.color.copy()
        end_color.s = 0.2
        while True:
            cells = sheep.FRONT_SPIRAL[current_cell +
                                       1:] + sheep.FRONT_SPIRAL[:current_cell]
            self.sheep.set_cell(sheep.FRONT_SPIRAL[current_cell], self.color)
            s = 0.3
            for cell, color in zip(
                    cells, color_transition(end_color, self.color,
                                            len(cells))):
                self.sheep.set_cell(cell, color)
            current_cell = (current_cell + 1) % len(sheep.FRONT_SPIRAL)
            yield self.speed
Ejemplo n.º 4
0
def morph_color(color1, color2, fract):
    morph_h = color1.h + ((color2.h - color1.h) * fract)
    morph_s = color1.s + ((color2.s - color1.s) * fract)
    morph_v = color1.v + ((color2.v - color1.v) * fract)

    return HSV(morph_h, morph_s, morph_v)
Ejemplo n.º 5
0
 def __init__(self, sheep_sides):
     self.name = 'Dan'
     self.cells = sheep_sides.both
     self.color = HSV(1,1,0)
     self.frame_delay = 0.1
Ejemplo n.º 6
0
                 turq=(128, 255, 128),
                 blue=(0, 0, 255),
                 cyan=(0, 255, 255),
                 magenta=(255, 0, 255))
HUES_primaries = dict(red=0,
                      orange=0.083333,
                      yellow=0.16667,
                      green=0.33333,
                      cyan=0.5,
                      blue=0.66666,
                      magenta=0.83334)
H = HUES_primaries
PRIMARY_OBJECTS = {}
for name, number in HUES_primaries.items():
    #print(name, number)
    PRIMARY_OBJECTS[name] = HSV(number, 1, 1)

available_patterns = [
    'create_random',
    'rainbow_test',
]


def create_random(projector, fps=30, duration=180):
    if fps < projector.fps:
        _fps = fps
    assert duration > 0
    count_down = _fps * duration
    print("test_generator")
    frame = 0
    _c = count(count_down, -1, -1)
Ejemplo n.º 7
0
    def __init__(self, sheep_sides):
        self.name = "Pinwheel"
        self.sheep = sheep_sides.both

        self.speed = 0.08
        self.color = HSV(0, 1.0, 1.0)
Ejemplo n.º 8
0
from pygame import time
import pygame
from random import randint, sample, choice
from grid import Grid
from color import Color, HSV, rgb_to_hsv, hsv_to_rgb, Primary
import opc
from copy import copy

clock = time.Clock()

client = opc.Client('localhost:7890')

c = count()
rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink', 'purple', 'blue', 'green', 'yellow', 'orange',
           'red']
frame = ([HSV(randint(0,100) / 100.0, 1, 1).rgb] * 40 for x in range(1000))


class Projector(object):
    def __init__(self, fps=60, grid=Grid()):
        self._fps = fps
        self._grid = grid
        self._patterns_master =[]

        self._clock = pygame.time.Clock()
        self._count = count()
        self.current_pattern = self._patterns[0]
        self._load_pattern
        self._set_frame()

    def _default(self):
Ejemplo n.º 9
0
from collections import namedtuple

from color import HSV

PlaneType = namedtuple("PlaneType", "type hsv")

DEFAULT = PlaneType("default", HSV(54, .3, 1.0))
STATIC = PlaneType("static", HSV(3, .99, 1.0))
A38 = PlaneType("A38", HSV(0., .99, 1.0))
B74 = PlaneType("B74", HSV(336, .974, 1.0))
B77 = PlaneType("B77", HSV(227, .99, 1.0))
B78 = PlaneType("B78", HSV(205, .94, 1.0))
B73 = PlaneType("B73", HSV(133, .89, 1.0))
A32 = PlaneType("A32", HSV(284, .12, 1.0))
A31 = PlaneType("A31", HSV(284, .12, 1.0))
A33 = PlaneType("A33", HSV(178, .198, 1.0))
A34 = PlaneType("A34", HSV(126, .96, 1.0))