/*
iphonedraw.pde
simple example to show how an iphone with oscemote
can act as an interface to a processing sketch
this example allows the user to draw using the iphone
multitouch interface - each finger is a new color
speed of finger movement translates to brush size
rob@rahji.com
http://www.robduarte.com
http://creativecommons.org/licenses/by/3.0/us/
*/
import oscP5.*;
import netP5.*;
// make an array of colors - could be more
color _red = color(255,0,0);
color _yellow = color(0,255,0);
color _green = color(0,0,255);
color[] colors = {_red, _yellow, _green};
OscP5 oscP5;
void setup() {
size(600,600);
frameRate(30);
noStroke();
oscP5 = new OscP5(this,8000); // start listening for osc messages on port 8000
oscP5.plug(this,"tuio","/tuio/2Dcur","sifffff"); // call tuio() for multitouch osc msgs
background(0);
}
// when a finger touches the iphone screen, draw a corresponding brushstroke
public void tuio(String s, int i, float fx, float fy, float fvx, float fvy, float fa) {
float maxvelocity = max(fvx,fvy); // fx/fy are location; fvx/fvy are speed of finger motion
int dotsize = int(map(maxvelocity,0.0,1.0,0.0,20.0)); // fvx/fvy is between 0-1; brush size is 0-20
int coloridx = int(i) % 3; // choose a color number (0-3) from the "finger number" (i)
fill(colors[coloridx]);
ellipse(
int(map(fx,0.0,1.0,0.0,600.0)), // fx is from 0-1, but screen width is up to 600
int(map(fy,0.0,1.0,0.0,600.0)), // fy is from 0-1, but screen width is up to 600
dotsize, // width
dotsize // height - could be different for a more oval shape, instead of a circle
);
}
void draw() {
}