Exemplo n.º 1
30
    def test_rgb_from_triplet(self):
        c = RGB(string="11,22,33")
        self.assertEquals(c.red, 11)
        self.assertEquals(c.green, 22)
        self.assertEquals(c.blue, 33)

        c = RGB(string="(11,22,33)")
        self.assertEquals(c.red, 11)
        self.assertEquals(c.green, 22)
        self.assertEquals(c.blue, 33)

        with self.assertRaises(RGBError):
            RGB(string="11,22,33,44")

        c = RGB(string="11,22,333")
        self.assertFalse(c.is_valid())
Exemplo n.º 2
3
    def __init__(self, sheep_sides):
        self.name = "ExampleShow"

        # Mirror drawing to both sides of the bus. Can also
        # treat the two sides separately.
        # choices: [both, party, business]
        self.cells = sheep_sides.both

        # color to draw
        self.color = RGB(255,0,0)
        # number of seconds to wait between frames
        self.frame_delay = 1.0
Exemplo n.º 3
0
    def next_frame(self):
        while True:

            if self.started_at == 0.0:
                self.started_at = time.time()

            elapsed_time = time.time() - self.started_at

            current_ix = int(math.floor(elapsed_time / self.dwell_time) % len(sheep.ALL))

            self.clear();

            focus = sheep.ALL[current_ix]
            self.both.set_cell(focus, RGB(255,0,0))

            edges = sheep.edge_neighbors(focus)
            print "edges = %s" % str(edges)
            if edges != None:
                for p in edges:
                    self.both.set_cell(p, RGB(0,255,0))

            vertices = sheep.vertex_neighbors(focus)
            if vertices != None:
                for p in vertices:
                    self.both.set_cell(p, RGB(0,0,255))

            yield 0.001
Exemplo n.º 4
0
    def __init__(self, sheep_sides):
        self.name = "WhiteGears"
        self.sheep = sheep_sides.both
        self.rate_min = 1
        self.rate_max = 10
        self.rate = randint(self.rate_min, self.rate_max)
        self.eqlizer = [0, 0, 0]  # Random initial values

        self.speed = 0.02

        self.gear_color = RGB(255, 255, 255)
        self.chain_color = RGB(255, 255, 255)

        self.last_osc = time.time()
        self.OSC = False  # Is Touch OSC working?

        self.REAR_SPIRAL = [24, 32, 35, 36, 33, 26, 25]
        self.CHAIN = [
            39, 40, 41, 42, 43, 37, 34, 30, 31, 22, 23, 3, 2, 1, 5, 6, 12, 11,
            15, 19
        ]

        self.gears = {}

        new_gear = Gear(self.sheep, sheep.FRONT_SPIRAL)
        self.gears['FRONT'] = new_gear

        new_gear = Gear(self.sheep, self.REAR_SPIRAL)
        self.gears['REAR'] = new_gear

        new_gear = Gear(self.sheep, self.CHAIN)
        self.gears['CHAIN'] = new_gear
Exemplo n.º 5
0
	def next_frame(self):
		while True:
				
			# Set background to inverse color
			
			self.sheep.set_all_cells( RGB(255,255,255))
			#self.sheep.set_all_cells( RGB(255 - self.color, 255 - self.color,	255 - self.color))
										  
			# Set all the mosaic cells to color
			
			self.sheep.set_cells(self.pixel1, RGB(self.color, self.color, self.color))
			
			# Change vertices generator
			
			if randint(0,100) == 1:
				self.key_cell = choice(self.sheep.all_cells())
				self.pixel1 = self.get_vertices(self.key_cell)
			
			# Change grey intensity
			self.color += self.dir
			if self.color < 0:
				self.color *= -1
				self.dir *= -1
			if self.color > 255:
				self.color = 255 - (self.color - 255)
				self.dir *= -1
				
			yield self.speed
Exemplo n.º 6
0
 def __init__(self, sheep_sides):
     self.name = "Firefly"
     self.sheep = sheep_sides.both
     self.yellow = RGB(255, 250, 0)
     self.black = RGB(0, 0, 0)
     self.contrast = 200
     self.col = 0
     self.dir = 1
     self.speed = 0.02
Exemplo n.º 7
0
    def next_frame(self):

        while True:
            self.tri_grid.clear()
            self.tri_grid.set_cell_by_cellid(rnd.randint(1, self.n_cells - 2),
                                             RGB(200, 255, 25))
            self.tri_grid.set_cell_by_cellid(rnd.randint(1, self.n_cells - 2),
                                             RGB(200, 10, 25))

            yield self.frame_delay
Exemplo n.º 8
0
    def __init__(self, sheep_sides):
        self.name = "White Snow"
        self.sheep = sheep_sides.both
        self.paths = []  # List that holds paths objects
        self.max_paths = 6
        self.decay = 1.0 / 3
        self.background = RGB(0, 0, 0)  # Always Black
        self.foreground = RGB(255, 255, 255)  # Always White

        self.speed = 0.05
Exemplo n.º 9
0
    def __init__(self, sheep_sides):
        self.name = "Hypnagogy"
        self.cells = sheep_sides.both

        self.hertz = 30
        self.speed = 1 / self.hertz
        print "Running at %d Hertz (%f delay)" % (self.hertz, self.speed)

        self.color1 = RGB(255, 148, 0)  # orange
        self.color2 = RGB(148, 0, 255)  # purple
Exemplo n.º 10
0
    def __init__(self, sheep_sides):
        self.name = "WhiteBlinky"
        self.sheep = sheep_sides.both
        self.faders = []  # List that holds Fader objects
        self.max_faders = 20
        self.aging = 0.1

        self.foreground = RGB(255, 255, 255)  # Sparkle color = white
        self.background = RGB(0, 0, 0)  # Background = black

        self.speed = 0.1
Exemplo n.º 11
0
    def __init__(self, sheep_sides):
        self.name = "Sparkle"
        self.sheep = sheep_sides.both

        self.speed = 0.05
        self.color = RGB(0, 255, 0)

        # set background to dim white
        self.background = RGB(255, 255, 255)
        self.background.v = 0.2

        self.neighbor_count = None
Exemplo n.º 12
0
    def __init__(self, sheep_sides):
        self.name = "WhitePathsTwo"
        self.sheep = sheep_sides.both
        self.paths = []  # List that holds paths objects
        self.max_paths = 2
        self.length = randint(60, 100)
        self.decay = 1.0 / self.length

        self.foreground = RGB(255, 255, 255)  # White
        self.background = RGB(50, 50, 50)  # Black

        self.speed = 0.2
Exemplo n.º 13
0
    def __init__(self, sheep_sides):
        self.name = "White Trails"
        self.sheep = sheep_sides.both
        self.paths = []  # List that holds paths objects
        self.max_paths = 3
        self.decay = 1.0 / 5
        self.length = 9
        self.trajectories = (sheep.LOW, sheep.MEDIUM, sheep.HIGH)
        self.foreground = RGB(0, 0, 0)  # Black
        self.background = RGB(255, 255, 255)  # White

        self.speed = 0.05
Exemplo n.º 14
0
    def __init__(self, sheep_sides):
        self.name = "ExampleShow"

        # Mirror drawing to both sides of the bus. Can also
        # treat the two sides separately.
        # choices: [both, party, business]
        self.cells = sheep_sides.both

        # color to draw
        self.color = RGB(255, 0, 0)
        # number of seconds to wait between frames
        self.frame_delay = 1.0
Exemplo n.º 15
0
    def __init__(self, sheep_sides):
        self.name = "Bee"
        self.sheep = sheep_sides.both

        self.last_osc = time.time()
        self.OSC = False  # Is Touch OSC working?

        self.stripe1 = RGB(255, 240, 0)  # Yellow
        self.stripe2 = RGB(0, 0, 0)  # Black

        self.contrast = 150  # 0-255 value adjusted by r-channel of Touch OSC

        self.speed = 0.5
Exemplo n.º 16
0
 def moneyShot(self, ejaculateSpeed, fullShaftRotation):
     self.speed = ejaculateSpeed
     shaft = fullShaftRotation[2]
     aDelta = int(time.time() / self.speed) % (len(self.moneyShotRotation))
     # color the asshole
     self.sheep.set_cells(self.butt, self.chocolateStarfish)
     # color the shaft
     self.sheep.set_cells(shaft, self.headTone)
     lastCells = None
     for i in range(len(self.moneyShotRotation)):
         if lastCells:
             self.sheep.set_cells(lastCells, RGB(0, 0, 0))
         lastCells = self.moneyShotRotation[i]
         self.sheep.set_cells(self.moneyShotRotation[aDelta], RGB(255, 255, 255))
Exemplo n.º 17
0
    def next_frame(self):
        while (True):

            # Fill in the background with black
            # Some times, flash white

            if randint(0, 20) == 1:
                background = RGB(255, 255, 255)
            else:
                background = RGB(0, 0, 0)

            self.sheep.set_all_cells(background)

            # Draw the gears
            self.gears['FRONT'].draw_gear(self.gear_color)
            self.gears['REAR'].draw_gear(self.gear_color)
            self.gears['CHAIN'].draw_gear(self.chain_color)

            # Move the gears

            if self.rate > 0:
                dir = 1  # Forward
            else:
                dir = -1  # Backwards

            self.gears['FRONT'].move_gear(dir)
            self.gears['REAR'].move_gear(dir)
            self.gears['CHAIN'].move_gear(dir)

            # Randomly change speeds

            if time.time() - self.last_osc > 120:  # 2 minutes
                self.OSC == False

            if self.OSC == False:
                self.gear_color += 1
                if self.gear_color > 1536:
                    self.gear_color -= 1536
                self.chain_color -= 1
                if self.chain_color < 0:
                    self.chain_color = MaxColor - 1

                if randint(0, 10) == 1:
                    self.rate += randint(-1, 1)
                    if self.rate > self.rate_max:
                        self.rate = self.rate_max
                    if self.rate < -1 * self.rate_max:
                        self.rate = -1 * self.rate_max
            yield (self.speed * (self.rate_max + 1 - abs(self.rate)))
Exemplo n.º 18
0
    def __init__(self, sheep_sides):
        self.name = "White One At A Time"
        self.sheep = sheep_sides.both

        self.speed = 0.1
        self.white = RGB(255, 255, 255)
        self.black = RGB(0, 0, 0)

        self.color = self.white

        # Blank the sheep to a random background color
        self.sheep.set_all_cells(self.black)

        # Shuffle the panels
        self.shuf_panels = self.sheep.all_cells()
        shuffle(self.shuf_panels)
Exemplo n.º 19
0
    def __init__(self, sheep_sides):
        self.name = "WhiteBounce"
        self.sheep = sheep_sides.both
        self.decay = 1.0 / 6
        self.paths = []  # List that holds paths objects
        self.trajectories = (sheep.LOW, sheep.MEDIUM, sheep.HIGH)
        self.background = RGB(0, 0, 0)  # Always Black
        self.foreground = RGB(255, 255, 255)  # White

        # Set up 3 balls on low, medium, and high levels

        for i in range(3):
            new_path = Path(self.sheep, self.trajectories[i], self.decay)
            self.paths.append(new_path)

        self.speed = 0.2
Exemplo n.º 20
0
class WhiteRandomOneColor(object):
	def __init__(self, sheep_sides):
		self.name = "White Random One Color"
		self.sheep = sheep_sides.both

		self.speed = 0.1

		self.color = RGB(255,255,255)	# White
		
		self.panel_map = {}	# Dictionary of panels: value is Panel object

		for cell in self.sheep.all_cells():
			newpanel = Panel()
			self.panel_map[cell] = newpanel

	def next_frame(self):
		while True:
			for cell, panel in self.panel_map.iteritems():

				adj_color = self.color.copy()
				adj_color.v = panel.intensity / 100.0
				self.sheep.set_cell(cell, adj_color)

				panel.update_panel()
			
			yield self.speed
Exemplo n.º 21
0
def Wheel(color):
    color = color % 1536  # just in case color is out of bounds
    channel = color / 255
    value = color % 255

    if channel == 0:
        r = 255
        g = value
        b = 0
    elif channel == 1:
        r = 255 - value
        g = 255
        b = 0
    elif channel == 2:
        r = 0
        g = 255
        b = value
    elif channel == 3:
        r = 0
        g = 255 - value
        b = 255
    elif channel == 4:
        r = value
        g = 0
        b = 255
    else:
        r = 255
        g = 0
        b = 255 - value

    return RGB(r, g, b)
Exemplo n.º 22
0
def gradient_color(color, fade_value):
    # Check limits
    if fade_value < 0: fade_value = 0
    if fade_value > 1: fade_value = 1

    return RGB(color.r * fade_value, color.g * fade_value,
               color.b * fade_value)
Exemplo n.º 23
0
def fade_color(color, fade_value):
    # Check limits
    if fade_value < -255: fade_value = -255
    if fade_value > 255: fade_value = 255

    return RGB(bump(color.r, fade_value), bump(color.g, fade_value),
               bump(color.b, fade_value))
Exemplo n.º 24
0
    def next_frame(self):
        xlen = len(self.tri_grid._triangle_grid)
        ylen = len(self.tri_grid._triangle_grid[0])
        x = 0
        y = 0
        while True:
            self.tri_grid.clear()

            print(f"x={x} y={y}")
            if y < ylen:
                for rows in self.tri_grid._triangle_grid:
                    cell = self.tri_grid._triangle_grid[x][y]
                    print("AAA", x, y, rows)
                    if cell is None:
                        pass
                    else:
                        self.tri_grid.set_cell_by_cellid(
                            cell.get_id(), RGB(255, 25, 25))
                    x += 1
                x = 0
                y += 1
            else:
                x = 0
                y = 0

            yield self.frame_delay
Exemplo n.º 25
0
 def __init__(self, sheep_sides):
     self.name = "White Starburst"
     self.sheep = sheep_sides.both
     self.starbursts = []  # List that holds Path objects
     self.max_starbursts = 4
     self.decay = 1.0 / 4
     self.length = 3
     self.background = RGB(50, 50, 50)
     self.speed = 0.2
Exemplo n.º 26
0
    def __init__(self, sheep_sides):
        self.name = "Paths Two"
        self.sheep = sheep_sides.both
        self.paths = []  # List that holds paths objects
        self.max_paths = 2

        self.foreground = randint(0, 1536)  # Path color
        self.background = RGB(0, 0, 255)  # Override with Touch OSC

        self.speed = 0.15
Exemplo n.º 27
0
    def __init__(self, sheep_sides):
        self.name = "Blinky"
        self.sheep = sheep_sides.both
        self.faders = []  # List that holds Fader objects
        self.max_faders = 15

        self.foreground = randint(0, 255)  # Sparkle color
        self.background = RGB(0, 255, 0)  # Override with Touch OSC

        self.speed = 0.1
Exemplo n.º 28
0
    def __init__(self, sheep_sides):
        self.name = "Trails"
        self.sheep = sheep_sides.both
        self.paths = []  # List that holds paths objects
        self.max_paths = 3
        self.trajectories = (sheep.LOW, sheep.MEDIUM, sheep.HIGH)
        self.foreground = randint(0, 1536)  # Path color
        self.background = RGB(255, 255, 255)  # Override with Touch OSC

        self.speed = 0.05
Exemplo n.º 29
0
    def next_frame(self):
        while (True):

            # Setup our colors
            colors = []

            if self.cm.modifiers[1]:
                # Ha! Jordan's colors...
                colors.append(RGB(255, 255, 27))
                colors.append(RGB(64, 255, 218))
                colors.append(RGB(245, 218, 64))
                colors.append(RGB(255, 140, 140))

            elif self.cm.modifiers[0]:
                colors = self.cm.chosen_colors

            else:
                # Default colors
                colors.append(geom.BLUE)
                colors.append(geom.DARKER_BLUE)
                colors.append(geom.WHITE)
                colors.append(geom.BLUE)

            bg = geom.DARK_RED

            sparkle_thresh = 0.0001 + (
                (self.cm.intensified + 1.0) / 2.0) * 0.010
            #sparkle_thresh = 0.005

            for pixel in geom.ALL:
                # Does it sparkle or not
                if random.random() < sparkle_thresh:
                    # Sparkle it
                    # It gets one of 4 inensities
                    clr = colors[random.randrange(len(colors))]
                    self.cells.set_cell(pixel, clr)

                else:
                    # No sparkle. Set to background
                    self.cells.set_cell(pixel, bg)

            yield self.frame_time
Exemplo n.º 30
0
    def __init__(self, sheep_sides):

        self.name = "FuckSession"
        self.createdAt = time.time()
        self.sheep = sheep_sides.both
        self.partyCells = sheep_sides.party
        self.businessCells = sheep_sides.business

        self.butt = [51, 52, 53, 54, 55]
        self.tipCellRotation = [[39], [39, 32], [39, 32, 35], [39, 32, 35, 36],
                                [39, 32, 35, 36], [39, 32, 35], [39, 32], [39]]
        self.moneyShotRotation = [[17], [17, 8], [17]]

        self.headTone = RGB(255, 200, 201)
        self.chocolateStarfish = RGB(148, 10, 0)
        self.shaftTone = RGB(239, 214, 189)

        self.speed = 1
        self.mode = "start"
        self.count = 0
Exemplo n.º 31
0
    def next_frame(self):
        last_cell = None
        while True:
            for cell in sheep.FRONT_SPIRAL:
                if last_cell:
                    self.sheep.set_cell(last_cell, RGB(0,0,0))
                self.sheep.set_cell(cell, self.color)
                last_cell = cell
                self.color.h = (self.color.h + 0.025) % 1

                yield self.speed
Exemplo n.º 32
0
    def __init__(self, sheep_sides):
        self.name = "TestControls"

        self.sheep_sides = sheep_sides
        self.both = sheep_sides.both

        self.p = sheep_sides.party_eye
        self.b = sheep_sides.business_eye
        self.background = RGB(203, 150, 109)

        self.started_at = 0.0
        self.dwell_time = 1.8
Exemplo n.º 33
0
    def __init__(self, sheep_sides):
        self.name = "Sparkle"
        self.sheep = sheep_sides.both

        self.speed = 0.05
        self.color = RGB(0,255,0)

        # set background to dim white
        self.background = RGB(255,255,255)
        self.background.v = 0.2

        self.neighbor_count = None
Exemplo n.º 34
0
	def __init__(self, sheep_sides):
		self.name = "WhiteCocoon"
		self.sheep = sheep_sides.both
		
		self.last_osc = time.time()

		self.color = RGB(255,255,255)	# White
		
		self.c_contrast = 100	# 0-255 value adjusted by g-channel of Touch OSC
		self.r_contrast = 50	# 0-255 value adjusted by b-channel of Touch OSC
				
		self.speed = 0.5
Exemplo n.º 35
0
	def __init__(self, sheep_sides):
		self.name = "White Random One Color"
		self.sheep = sheep_sides.both

		self.speed = 0.1

		self.color = RGB(255,255,255)	# White
		
		self.panel_map = {}	# Dictionary of panels: value is Panel object

		for cell in self.sheep.all_cells():
			newpanel = Panel()
			self.panel_map[cell] = newpanel
Exemplo n.º 36
0
class Sparkle(object):
    def __init__(self, sheep_sides):
        self.name = "Sparkle"
        self.sheep = sheep_sides.both

        self.speed = 0.05
        self.color = RGB(0,255,0)

        # set background to dim white
        self.background = RGB(255,255,255)
        self.background.v = 0.2

        self.neighbor_count = None

    def set_param(self, name, val):
        # name will be 'colorR', 'colorG', 'colorB'
        rgb255 = int(val * 0xff)
        if name == 'colorR':
            self.color.r = rgb255
        elif name == 'colorG':
            self.color.g = rgb255
        elif name == 'colorB':
            self.color.b = rgb255

    def clear(self):
        self.sheep.set_all_cells(self.background)

    def next_frame(self):
        while True:

            color = self.color.copy()
            start = random.choice(sheep.ALL)

            for i in range(random.randint(3,5)):

                neighbors = sheep.edge_neighbors(start)
                if len(neighbors) > 2:
                    edges = random.sample(neighbors, 2)
                else:
                    edges = []

                self.clear()
                color.v = 1.0
                self.sheep.set_cell(start, color)
                color.v = 0.8
                self.sheep.set_cells(edges, color)
                yield self.speed

            self.clear()
            yield 1.0
Exemplo n.º 37
0
class Neighbors(object):
    def __init__(self, sheep_sides):
        self.name = "Test neighbors"
        self.sheep = sheep_sides.both

        self.color = RGB(0, 255, 0)
        self.speed = 1.0

    def set_param(self, name, val):
        # name will be 'colorR', 'colorG', 'colorB'
        rgb255 = int(val * 0xFF)
        if name == "colorR":
            self.color.r = rgb255
        elif name == "colorG":
            self.color.g = rgb255
        elif name == "colorB":
            self.color.b = rgb255

    def next_frame(self):
        while True:
            for cellnum in sheep.ALL:
                self.sheep.clear()  # unnecessary for it to do a go here?

                col = self.color.copy()
                # set the primary panel to the base color
                self.sheep.set_cell(cellnum, col)

                # set edge neighbors to 80% brightness
                col.v = 0.8
                self.sheep.set_cells(sheep.edge_neighbors(cellnum), col)

                # set vertex neighbors to 20% brightness
                col.v = 0.2
                self.sheep.set_cells(sheep.vertex_neighbors(cellnum), col)

                yield self.speed
Exemplo n.º 38
0
    def test_rgb_from_colors(self):
        c = RGB()
        self.assertEquals(c.red, -1)
        self.assertEquals(c.green, -1)
        self.assertEquals(c.blue, -1)
        self.assertFalse(c.is_valid())

        c = RGB(red=11, green=22, blue=33)
        self.assertEquals(c.red, 11)
        self.assertEquals(c.green, 22)
        self.assertEquals(c.blue, 33)

        c = RGB(green=22, red=11, blue=33)
        self.assertEquals(c.red, 11)
        self.assertEquals(c.green, 22)
        self.assertEquals(c.blue, 33)

        c = RGB(red=256, green=44, blue=55)
        self.assertFalse(c.is_valid())
Exemplo n.º 39
0
    def __init__(self, sheep_sides):
        self.name = "Test neighbors"
        self.sheep = sheep_sides.both

        self.color = RGB(0, 255, 0)
        self.speed = 1.0
Exemplo n.º 40
0
class ExampleShow(object):
    def __init__(self, sheep_sides):
        self.name = "ExampleShow"

        # Mirror drawing to both sides of the bus. Can also
        # treat the two sides separately.
        # choices: [both, party, business]
        self.cells = sheep_sides.both

        # color to draw
        self.color = RGB(255,0,0)
        # number of seconds to wait between frames
        self.frame_delay = 1.0

    def set_param(self, name, val):
        """
        Receive a command from OSC or other external controller
        'name' is the name of the value being set
        'val' is a floating point number between 0.0 and 1.0
        See 'doc/OSC.md' for details on the named parameters

        This example responds to three color sliders (corresponding
        to R, G and B) in the OSC controller to set the primary
        color of the show.  RGB color values range from 0-255, so
        we must convert the input value.
        """
        # name will be 'colorR', 'colorG', 'colorB'
        rgb255 = int(val * 255)
        if name == 'colorR':
            self.color.r = rgb255
        elif name == 'colorG':
            self.color.g = rgb255
        elif name == 'colorB':
            self.color.b = rgb255

    def next_frame(self):
        """
        Draw the next step of the animation.  This is the main loop
        of the show.  Set some pixels and then 'yield' a number to
        indicate how long you'd like to wait before drawing the next
        frame.  Delay numbers are in seconds.
        """
        while True:
            # clear whatever was drawn last frame
            self.cells.clear()

            # choose a random panel on the sheep
            panel_id = random.choice(sheep.ALL)

            # set the chosen panel to the current color
            self.cells.set_cell(panel_id, self.color)

            # make the neighboring panels dimmer (80% brightness)
            # first find out all of the neighboring panels
            neighbors = sheep.edge_neighbors(panel_id)

            # make a copy of the color so it's safe to change
            dim_color = self.color.copy()
            dim_color.v = 0.8

            # then set multiple panels in one call
            self.cells.set_cells(neighbors, dim_color)

            # then wait to draw the next frame
            yield self.frame_delay