Skip to content

Instantly share code, notes, and snippets.

@tomie89
Created November 26, 2013 18:49
Show Gist options
  • Select an option

  • Save tomie89/7663686 to your computer and use it in GitHub Desktop.

Select an option

Save tomie89/7663686 to your computer and use it in GitHub Desktop.
hallo Fabian,
// kannst du dir erst vielleicht meinen sketch anschauen, dann kannst du mich besser verstehen, worum ich das meine:
// we need to import the TUIO library
// and declare a TuioProcessing client variable
import TUIO.*;
import java.util.*;
TuioProcessing tuioClient;
// these are some helper variables which are used
// to create scalable graphical feedback
float cursor_size = 50;
float table_size = 1100;
float scale_factor = 10;
PFont font;
int mx,my; //definiert 2 globale variablen
void setup()
{
//size(screen.width,screen.height);
size(700,700);
fill(255);
strokeWeight(3);
frameRate(100);
font = createFont("Chalkduster", 30);
scale_factor = height/table_size;
// we create an instance of the TuioProcessing client
// since we add "this" class as an argument the TuioProcessing class expects
// an implementation of the TUIO callback methods (see below)
tuioClient = new TuioProcessing(this);
}
// within the draw method we retrieve a Vector (List) of TuioObject and TuioCursor (polling)
// from the TuioProcessing client and then loop over both lists to draw the graphical feedback.
void draw(){
background(0);
textFont(font,30*scale_factor);
gesicht(); //zeichnet den kopf und den schnabel
augen(250,height/2); //zeichnet das linke auge
augen(350,height/2); //zeichnet das rechte auge
float cur_size = cursor_size*scale_factor;
Vector tuioCursorList = tuioClient.getTuioCursors();
for (int i=0;i<tuioCursorList.size();i++) {
TuioCursor tcur = (TuioCursor)tuioCursorList.elementAt(i);
Vector pointList = tcur.getPath();
if (pointList.size() > 0) {
stroke(255,0,0);
TuioPoint start_point = (TuioPoint)pointList.firstElement();
for (int j=0;j<pointList.size();j++) {
TuioPoint end_point = (TuioPoint)pointList.elementAt(j);
float startx = start_point.getScreenX(width);
float starty = start_point.getScreenY(height);
float endx = end_point.getScreenX(width);
float endy = end_point.getScreenY(height);
line(startx,starty, endx,endy);
start_point = end_point;
}
stroke(0,0,255);
fill(0,255,0);
ellipse( tcur.getScreenX(width), tcur.getScreenY(height), cur_size, cur_size);
fill(0);
text(""+ tcur.getCursorID(), tcur.getScreenX(width)-5, tcur.getScreenY(height)+5);
}
}
}
void gesicht() { //funktion ohne rückgabewert
fill(0,100,200);
ellipse (300,400,260,260);
fill(200);
}
void augen(int x,int y) { //funktion ohne rückgabewert
fill(255);
ellipse(x,y,90,90);
mx=mouseX-x;
my=mouseY-y;
fill(255,0,0);
ellipse(x+mx/10,y+my/10,40,40);
}
// allerdings weiß ich nicht wie ich eine rote streich behalten kann, die von mausbewegung erzeugt worden ist, so dass ich das gesicht zusötzlich zum beispiel Haare, Ohren, Mund, Piercing zeichnen kann, ohne streichen dabei verschwunden werden zu lassen. Ich möchte auch jeden streichen einen eigene farbe nach je Touch eingeben - wie geht es das?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment