コード例 #1
0
    def setupTextures(self):
        content = Content("Aurora")

        ch1_file = content.add_asset('iChannel0.png')
        ch2_file = content.add_asset('iChannel1.png')
        self.img = ofImage(ch1_file)
        self.img2 = ofImage(ch2_file)
        self.fbo2 = ofFbo()
        self.fbo2.allocate(self.width, self.height)
        self.fbo2.begin()
        self.img2.draw(0, 0, self.width, self.height)
        self.fbo2.end()
コード例 #2
0
from protopixel import Content
from openframeworks import *

import os.path
from tempfile import mkdtemp

content = Content("Ripple")

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')

content.add_parameter("speed", min=0.01, max=1.0, value=0.033)

def setup():
    if content['shader path']:
        shader_path_changed(content['shader path'])

    with open(frag_file,'w') as f:
        f.write(frag_contents_prefix)
        f.write(frag_contents)
        f.write(frag_contents_suffix)
    with open(vert_file,'w') as f:
        f.write(vert_contents)
    shader.load(shader_file_of)
コード例 #3
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()

コード例 #4
0
from openframeworks import *
from protopixel import Content
from tempfile import mkdtemp
import os.path
from random import randint
import imp

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)
コード例 #5
0
from random import randint
import math

print "Strobe"

#a global variable
color = ofColor(255)
elapsedTime = 0.0
startColorIndex = 1
endColorIndex = 2
brightness = 0
scaleFactor = 10.0
currentSpeed = 0.1
speedFactor = 7

content = Content("Strobe")
content.FBO_SIZE = (170, 170)  #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("stage_mode", value=False)


@content.parameter_changed('change_hue')
def parameter_changed(value):
    """
    This function is called every time a a_integer is changed.
コード例 #6
0
from openframeworks import *
from protopixel import Content
from random import randint
import math

print "BlackoutSections"

#a global variable
size = 170
currentTransparency = []
targetTransparency = []
numSections = 5
onTransparency = 10

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

content.add_parameter("_1", value=False)
content.add_parameter("_2", value=False)
content.add_parameter("_3", value=False)
content.add_parameter("_4", value=False)
content.add_parameter("_5", value=False)


@content.parameter_changed('_1')
def parameter_changed(value):

    global targetTransparency, onTransparency

    if value == True:
        targetTransparency[0] = 255
コード例 #7
0
from protopixel import Content
from openframeworks import *

import os.path
from tempfile import mkdtemp

#a global variable
color = ofColor(255)
elapsedTime = 0.0
startColorIndex = 1
endColorIndex = 2
scaleFactor = 10.0
currentTime = 0
timeFactor = 5.0

content = Content("Shader")

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')

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)
コード例 #8
0
from openframeworks import *
from protopixel import Content
from tempfile import mkdtemp
import os.path
from random import randint
import imp

content = Content("ProtoPixeFrames")

print "ProtoPixeFrames"

color = ofColor(255)
shader = ofShader()
targetAlpha = 1.0
currentAlpha = 0.0

size = 10
content.FBO_SIZE = (size, size)
content.add_parameter("gamma", min=0.0, max=1.0, value=0.9)
content.add_parameter("Color", type="color", value=ofColor(255, 255, 255))

rainbow_file = content.add_asset("rainbow.py")
rainbow = imp.load_source('rainbow', rainbow_file)

square_file = content.add_asset("square.py")
square = imp.load_source('square', square_file)


def setup():
    """
    This will be called at the beggining, you set your stuff here
コード例 #9
0
from openframeworks import *
from protopixel import Content
from tempfile import mkdtemp
import os.path
from random import randint
import imp

from OSC import OSCClient, OSCMessage

content = Content("ProtoPixelDress")

sparkle_file = content.add_asset("sparkle.py")
sparkles = imp.load_source('sparkles', sparkle_file)

rainbow_file = content.add_asset("rainbow.py")
rainbow = imp.load_source('rainbow', rainbow_file)

fade_file = content.add_asset("fade.py")
fade = imp.load_source('fade', fade_file)

waves_file = content.add_asset("waves.py")
waves = imp.load_source('waves', waves_file)

circles_file = content.add_asset("circles.py")
circles = imp.load_source('circles', circles_file)

OSC_DEST_IP = "localhost"
OSC_BROADCAST_IP = "192.168.8.255"
OSC_BROADCAST_PORT = 2346
OSC_DEST_PORT = 2345
コード例 #10
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
コード例 #11
0
from openframeworks import *
from protopixel import Content
import numpy as np

content = Content("Assets example Script")


# If you want to use an external asset inside a script
# you can declare it like this:

cat_file = content.add_asset('cat.jpeg')

# This could be a file or a folder.

# This serves two different purposes:
# - It is equivalent to os.path.join(os.path.dirname(__file__),'cat.jpeg'),
#   so it allows you to get a valid path for an asset that is relative to
#   the script, but is easier to write.
# - It tells ProtoPixel Create about these files, so it can pack them when
#   exporting a project.

def setup():
    global image
    image = ofImage(cat_file)
    content.FBO_SIZE = (int(image.getWidth()), int(image.getHeight()))

def draw():
    image.draw(0,0)

コード例 #12
0
import socket
import struct
import sys

import time
from time import time as tt
import numpy as np
import os.path

from openframeworks import *
from protopixel import Content

UDP_IP = "192.168.8.237"
UDP_PORT = 2390

content = Content('Virtual controller')
content.add_parameter("FPS_LIMIT", min=0, max=60, value=30)

content.add_parameter("Controller1", value=False)
content.add_parameter("IP_1", value="192.168.8.237")

content.add_parameter("Controller2", value=False)
content.add_parameter("IP_2", value="192.168.8.238")

content.add_parameter("Controller3", value=False)
content.add_parameter("IP_3", value="192.168.8.239")

content.add_parameter("Controller4", value=False)
content.add_parameter("IP_4", value="192.168.8.240")

content.add_parameter("Controller5", value=False)
コード例 #13
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('html-receive.html')


@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.
    """
    global color
    r = data["R"]
    g = data["G"]
    b = data["B"]
    color = ofColor(r, g, b)


def draw():
コード例 #14
0
from openframeworks import *
from protopixel import Content

content = Content('Parameters Script')

# You can define parameters that will show in the GUI
# The supported parameter types are:
# boolean
#   True or False
# integer
# float
#   Can define a min and max
# string
#   A simple string
# filepath
#   A string, but a button for opening a file will appear
# color
#   An instance of ofColor (r,g,b,a).
# button
#   A function that can be triggered

# Use content.add_parameter to define all parameters of the script that will be exposed to the GUI
# The first argument is the name of the variable,
# the keywords are the options.
# Booleans do not have options other that its initial value.
# Initial value is optional.
# Pay attention to the type of the value. If you mix them you will
# get incorrect types (1 vs 1.0 for int and float, for instace)
content.add_parameter("a_boolean", value=True)

# Integer can also define min and max of its value.
コード例 #15
0
from openframeworks import *
from protopixel import Content
from tempfile import mkdtemp
import os.path
from random import randint
import imp

content = Content("IngoSchuster")

sunset_file = content.add_asset("Sunset.py")
sunset = imp.load_source('sunset', sunset_file)

clouds_file = content.add_asset("Clouds.py")
clouds = imp.load_source('clouds', clouds_file)

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

print "IngoSchuster"

#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
コード例 #16
0
# Activating/deactivating contents by OSC or button

# In this scenario we have two contents that we want to control, their names are "content1" and "content2"

from protopixel import Content

# We need to change the configuration of other contents
from protopixel.core import setConfContent

# Create ProtoPixel Create content
content = Content('OSC and button Content enabler example')

# content.add_button decorator adds a button on the GUI that executes the decorated function
# content.OSC decorator let's you define an OSC entry point for a given address. In this case
# '/scene1' address with no arguments will execute this function
@content.add_button('scene1')
@content.OSC('/scene1')
def enable_scene1():
	# When we receive an OSC packet in '/scene1' or click on 'scene1' button, we activate content1
	# and deactivate content2
	setConfContent('content1','enabled',True)
	setConfContent('content2','enabled',False)


@content.add_button('scene2')
@content.OSC('/scene2')
def enable_scene2():
	# When we receive an OSC packet in '/scene2' or click on 'scene2' button, we activate content2
	# and deactivate content1
	setConfContent('content1','enabled',False)
	setConfContent('content2','enabled',True)
コード例 #17
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))
コード例 #18
0
from openframeworks import *
from protopixel import Content
import numpy as np

content = Content("Audio Script")


def draw():
    """
    To pocess audio input, we can use the audio input buffer.
    >>> content.get_sound_buffer() #get audio buffer as a numpy array
    """
    buffer = content.get_sound_buffer()

    # get the absolute values
    buffer = np.abs(buffer)

    # get the sum of all values, to measure the energy
    energy = int(buffer.sum())

    # we use the energy to change the color
    ofClear(min(255, energy), 0, 0, 255)
コード例 #19
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)
コード例 #20
0
from openframeworks import *
from protopixel import Content
from tempfile import mkdtemp
import os.path
from random import randint
import imp

content = Content("IngoSchusterclouds")

clouds_file = content.add_asset("Clouds.py")
clouds = imp.load_source('clouds', clouds_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.9)
コード例 #21
0
from openframeworks import *
from protopixel import Content
from random import randint
import math

print "Hello ProtoPixel"

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

#a global variable
counter = 0
amplitudes = []


# None of the following functions are mandatory, they can be omitted


def setup():
    global x_spacing, wave_width, theta, period, dx, max_amplitude, amplitudes

    ofBackground(255, 255, 255)
    ofSetFrameRate(25)
    ofEnableAlphaBlending()
    ofEnableSmoothing()
    # distance between each horizontal point (in pixels)
    x_spacing = 5
    # width of the wave
    wave_width = 170
    # current angle
    theta = 0.0
コード例 #22
0
from protopixel import Content
from openframeworks import *

import os.path
from tempfile import mkdtemp

content = Content("Shader")
content.add_parameter("shader path", type="filepath")
content.add_parameter("speed", value=1.0, min=0.0, max=10.0)
content.add_parameter("reset 24h", value=False)

side = 256
content.FBO_SIZE = (side,side)
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')

def setup():
    if content['shader path']:
        shader_path_changed(content['shader path'])

def draw():
    ofClear(0,0,0,255)
    if shader.isLoaded():
        if content['reset 24h']:
            time = ofGetElapsedTimeMillis() % 86400000
            time = time / 1000.0
        else:
コード例 #23
0
from openframeworks import *
from protopixel import Content
import numpy as np

# We neeed access to low level API calls for communication with core
from protopixel.core import setConfContent, callParameterContent

content = Content("Video Script")


def setup():
    print "setup player"


def draw():
    pass


@content.OSC('/column2P/1')
def video_play(action):
    """
    This function handles OSC user input in address "/acc", with 3 arguments: x,y,z.
    Use pl.OSC decorator to define handles like this. Multiple scripts can listen to
    the same address simultaneously.
    """
    print("WORKING!")
    print action

    if action == True:
        callParameterContent("outro2", "params:resume")
        print "Play"
コード例 #24
0
from openframeworks import *
from protopixel import Content
from protopixel.core import (getContents, getWorkSpaceItems, getConfContent,
                             setConfContent)

size = 255

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

content = Content('Custom OSC Script')
content.FBO_SIZE = (size, size)


def update():
    """
    As we receive these messages at a lower rate than the framerate, we use a running
    average to interpolate between values.
    """
    pass


def draw():
    """
    We use r,g,b to draw the three bars.
    """
    pass

コード例 #25
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)
コード例 #26
0
from protopixel import Content

content = Content('Remote Web Interface')

content.web_path('remote')  # directory relative to this file
コード例 #27
0
width = size
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
コード例 #28
0
from openframeworks import *
from protopixel import Content

from OSC import OSCClient, OSCMessage

OSC_DEST_IP = "localhost"
OSC_DEST_PORT = 3334

content = Content('Custom OSC Sending Script')

# To send OSC messages we need an OSC Client
oscclient = OSCClient()


def update():
    message = OSCMessage()  #Create the OSC Message
    message.setAddress("/myoscaddress")  #Define the OSC Address
    message.append(44)  #first argument
    message.append(11)  #second argument
    message.append(4.5)  #third argument
    oscclient.sendto(message, (OSC_DEST_IP, OSC_DEST_PORT))  #send osc message