IFD:PhysicalComp2011/Julia Putscher/Codes for Processing: Difference between revisions
(Created page with "==Processing Code - Generating Graphs== void setup(){ <br> size(1000,600); <br> noStroke(); <br> smooth(); <br> } <br> <br> <br> void draw(){ <br> background(0); <br> String lin...") |
|||
Line 128: | Line 128: | ||
<br> | <br> | ||
noFill(); | noFill(); | ||
<br> | |||
<br> | <br> | ||
beginShape(); | beginShape(); | ||
<br> | <br> | ||
for (int i = 6 ; i < lines.length; i++) { | for (int i = 6 ; i < lines.length; i++) { | ||
Line 150: | Line 150: | ||
<br> | <br> | ||
vertex(i*2,200-zahl); | vertex(i*2,200-zahl); | ||
<br> | <br> | ||
prePointi = i; | prePointi = i; | ||
Line 159: | Line 158: | ||
<br> | <br> | ||
endShape(); | endShape(); | ||
<br> | |||
<br> | <br> | ||
// int p = millis()/1000; | // int p = millis()/1000; | ||
Line 166: | Line 166: | ||
<br> | <br> | ||
int theTime = millis()/1000; | int theTime = millis()/1000; | ||
<br> | <br> | ||
fill(200,220,0); | fill(200,220,0); | ||
Line 173: | Line 172: | ||
<br> | <br> | ||
strokeWeight(0); | strokeWeight(0); | ||
<br> | |||
<br> | <br> | ||
beginShape(); | beginShape(); |
Revision as of 13:11, 6 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;
}
}