コード例 #1
0
content = Content("IngoSchusterAurora")

aurora_file = content.add_asset("Aurora.py")
aurora = imp.load_source('aurora',aurora_file)

print "IngoSchusterSunset"


#a global variable
num_modes = 3
elapsedTime = 0.0
change_time = 350
width = 600
height= 100
content.FBO_SIZE = (width,height) #optional: define size of FBO, default=(100,100)
targetAlpha = 1.0
currentAlpha = 0.0
energy = 1.0
fbo = ofFbo()
fboVisuals = ofFbo()
shader = ofShader()
mode = 0

content.add_parameter("gamma", min=0.0, max=1.0, value=0.85)


def setup():
    """
    This will be called at the beggining, you set your stuff here
    """
コード例 #2
0
height =  size
color = ofColor(255)
elapsedTime = 0.0
elapsedTimeSquares = 0.0
startColorIndex = 1
endColorIndex = 2
scaleFactor = 10
squareScaleFactor = 2.0


rows = [ 0.0069, 0.055, 0.102, 0.151, 0.234926, 0.284, 0.331, 0.38, 0.479, 0.528, 0.575, 0.625, 0.707, 0.756, 0.803, 0.899, 0.948, 0.994]
cols = [ 0.026, 0.107, 0.186, 0.268089, 0.35, 0.428, 0.508, 0.591, 0.67, 0.751, 0.831, 0.912, 0.99]


content = Content("MinimalSquares")
content.FBO_SIZE = (size,size) #optional: define size of FBO, default=(100,100)

content.add_parameter("color1", type="color", value=ofColor(255, 255, 255))
content.add_parameter("color2", type="color", value=ofColor(255, 255, 255))
content.add_parameter("color3", type="color", value=ofColor(255, 255, 255))
content.add_parameter("change_hue", value=True)
content.add_parameter("color_speed", min=0.00, max=1.0, value=0.1)
content.add_parameter("speed", min=0.0, max=1.0, value=0.1)
content.add_parameter("num_squares", min=0, max=20, value=1)
content.add_parameter("stage_mode", value=False)


class Square:
    size = 570
    height = 4
    width = 4
コード例 #3
0
from protopixel import Content
from openframeworks import *

import os.path
from tempfile import mkdtemp

content = Content("SnowFlakes")

side = 256
content.FBO_SIZE = (side, side)
shaderfile = content.add_asset('shader')
shader = ofShader()

temp_dir = mkdtemp()
frag_file = os.path.join(temp_dir, 's.frag')
vert_file = os.path.join(temp_dir, 's.vert')
shader_file_of = os.path.join(temp_dir, 's')

#a global variable
color = ofColor(255)
elapsedTime = 0.0
startColorIndex = 1
endColorIndex = 2
scaleFactor = 10
speedFactor = 0.6

content.add_parameter("color1", type="color", value=ofColor(255, 255, 255))
content.add_parameter("color2", type="color", value=ofColor(255, 255, 255))
content.add_parameter("color3", type="color", value=ofColor(255, 255, 255))
content.add_parameter("change_hue", value=True)
content.add_parameter("color_speed", min=0.00, max=1.0, value=0.1)
コード例 #4
0
from openframeworks import *
from protopixel import Content

# color is the current color displayed
color = ofColor(255, 255, 255)

content = Content("Remote Interface Script")
size = 255

content.FBO_SIZE = (size, size)

# Here we specify where the remote interface (HTML) is.
# In this case, we have the index.html file in a folder
# called "remote_interface"
content.web_path('remote_interface')


@content.websocket.receive
def websocket(ws, data):
    """
    This function handles user input through a websocket, as provided in /pl.js library.
    Use content.websocket.receive decorator to define handles like this.
    In this case we send the accelerometer readings of the device (x,y,z).
    `ws` is a websocket, data the data comming through the websocket. You can send data
    with `ws.send()`.
    """
    global color
    r = normalize(data["x"])
    g = normalize(data["y"])
    b = normalize(data["z"])
    color = ofColor(r, g, b)
コード例 #5
0
from protopixel import Content
from openframeworks import *

X = 0.0
Y = 0.0

mode = 'rest'

content = Content('Orientation Script')
content.web_path('orientation')

content.FBO_SIZE = (500, 500)


class Autoscale(object):
    def __init__(self, min_value, max_value):
        self.min_out = min_value
        self.max_out = max_value
        self.spread_out = self.max_out - self.min_out
        self.min = self.max = None

    def __call__(self, val):
        if self.min is None:
            self.min = self.max = val
            return self.min_out + (self.spread_out) / 2.0

        self.min = min(self.min, val)
        self.max = max(self.max, val)

        return self.min_out + self.spread_out * ((val - self.min) /
                                                 (self.max - self.min))
コード例 #6
0
from openframeworks import *
import numpy as np
from protopixel import Content

# You can paint directly your light points by using numpy arrays

content = Content('Pixel Draw Script')
content.FBO_SIZE = (170, 170)

# we can precalculate this
center = np.array(content.FBO_SIZE) / 2


def draw_pixels(position_array, colors_array):
    """
    This function is called at every frame, with two arguments:
    * position_array is an array of 2D positions of all our lights
    * colors_array is an array of RGBA color components that we have
        to fill in order to "paint" our leds

    Please note that we have to CHANGE the contents of colors_array,
    not to assign a new array to the variable:

    >>> colors_array[:] = computed_colors # Correct
    >>> colors_array = computed_colors # Incorrect
    """
    t = ofGetElapsedTimef()
    dx = position_array[:, 0] - center[
        0]  # position_array[:,0] is all x positions
    dy = position_array[:, 1] - center[
        1]  # position_array[:,1] is all y positions
コード例 #7
0
# This file is part of the ProtoPixel Library
from protopixel import Content
from openframeworks import *
from collections import namedtuple

content = Content('Paint')
content.add_parameter('size', value=300, min=0, max=1024)
content.add_parameter('clear', type='button')

firstrun = True
Finger = namedtuple('Finger', ['x', 'y', 'size', 'color'])
fingers = []

content.FBO_SIZE = (300, 300)
content.web_path('paint')


@content.parameter_changed('size')
def size_changed(size):
    content.FBO_SIZE = (size, size)


@content.websocket.receive
def websocket(ws, data):
    if data['event'] == "draw":
        getfinger(data['x'] * content.FBO_SIZE[0],
                  data['y'] * content.FBO_SIZE[1], data['color'])
    elif data['event'] == "clear":
        clear()