IFD:PhysicalComp2011/Julia Putscher/Codes for Processing: Difference between revisions

From Medien Wiki
 
(No difference)

Latest revision as of 00:07, 8 April 2012

Processing Code - Generating Graphs

void setup(){
size(1000,600);
noStroke();
smooth();
}


void draw(){
background(0);
String lines[] = loadStrings("25.01_4.csv");
fill(70,71,73);
rect(0,10,1000,200);
textSize(15);
text("Julia Putscher & Reinhard v.d.Waydbrink",10,30);
for (int i = 6 ; i < lines.length; i++) {
String p[] = split(lines[i],',');
// println(p[1]);
float zahl = Float.parseFloat(p[1]);
fill(153,154,159);
if(zahl>=1){
fill(191,217,30);
rect((i*2),10,2,200);
fill(255);
}
if(zahl>=85){
fill(162,184,25);
rect((i*2),10,2,200);
fill(255);
}
if(zahl==0){
fill(223,253,35);
rect((i*2),10,2,200);
fill(255);
}
rect((i*2),200-zahl,1,zahl); }
}

Processing Code - Generating Heartbeat Line

void setup(){
size(1000,600);
noStroke();
smooth();
}


float prePointi = 0;
float prePointZahl = 0;
boolean playing = false;
float playpunkt = 0;


void draw(){
background(50);
String lines[] = loadStrings("23.01.csv");
noStroke();
fill(200,220,0);
rect(width-200,10,200,30);
fill(50);
textAlign(LEFT);
textSize(15);
text("PLAY",width-180, 30);
fill(200,220,0);

rect(0,50,1000,150);
textSize(15);
text("Julia Putscher & Reinhard v.d.Waydbrink",10,30);
noFill();

beginShape();
for (int i = 6 ; i < lines.length; i++) {
String p[] = split(lines[i],',');
// println(p[1]);
float zahl = Float.parseFloat(p[1]);

strokeWeight(5);
strokeCap(ROUND);
stroke(255);
//line(prePointi*2,200-prePointZahl,i*2,200-zahl);
vertex(i*2,200-zahl);
prePointi = i;
prePointZahl = zahl;
}
endShape();

// int p = millis()/1000;

if(playing==true){
int theTime = millis()/1000;
fill(200,220,0);
translate(theTime*2,200);
strokeWeight(0);

beginShape();
vertex(10,0);
vertex(20,20);
vertex(0,20);
endShape(CLOSE);

textAlign(CENTER);
text(theTime,10,32);
String heartrate[] = split(lines[theTime+6],',');
float heartratefloat = Float.parseFloat(heartrate[1]);
fill(255,0,0);
text(heartrate[1],40,5-heartratefloat);
fill(255,0,0);
translate(0,0-heartratefloat);

beginShape();
vertex(30,-10);
vertex(30,10);
vertex(10,0);
endShape(CLOSE);

println(theTime);
}
}

void mousePressed(){
if(mouseX>=width-200 && mouseY<=50){
println("heloo");
playing= true;
}
}