Cleaning up the code

Just cleaned it up a little, and added some extra float values so I could use more than one at any one time.

float myTime;
float mySpeed;
float myHeart;
int index; // The global index variable
String[] time;
String[] heart;
String[] speed;

void setup(){

size (1200, 1000);
smooth();
frameRate(15);

time = loadStrings(“time.csv”);
heart = loadStrings(“heart_rate.csv”);
speed = loadStrings(“speed.csv”);

}

void draw(){
fill (255, 7);
rect (0, 0, width, height);

mySpeed = 10 * (new Float(speed[index]));
myTime = 10 * (new Float(time[index]));
myHeart = 10 * (new Float(time[index]));

noFill();

fill (myHeart, 100, myHeart);
rect(index * 10, mySpeed * 6, myHeart * 6, myHeart * 1);
ellipse(index * 10, myTime * 20, myTime * 5, myTime * 5);

index = index +1; // Check when reaching 120, stop or restart at 0
if (index > 119) {
index = 0;
}
noFill();
}

Got the loop in

Sorted the loop, it was relatively simple, just a case of adding this to the end.

index = index +1; // Check when reaching 120, stop or restart at 0
if (index > 119) {
index = 0;

Useful frogs.

Thanks to a very helpful Frenchman on the Processing forums, my code now makes sense/runs as I wanted it to.
Zing!

float myValue;
int index; // The global index variable
String[] time;
String[] heart;
String[] speed;

void setup(){

size (1200, 1000);
frameRate(10);

time = loadStrings(“time.csv”);
heart = loadStrings(“heart_rate.csv”);
speed = loadStrings(“speed.csv”);

}

void draw(){
float a = new Float(speed[index]);
line(index * 10, a * 100, a * 50, a * 50);

myValue = 10 * (new Float(time[index]));
ellipse(index * 10, myValue * 20, myValue * 5, myValue * 5);

index++; // Check when reaching 120, stop or restart at 0
}

Processing.

I hate it.
Well, not so much now that I’ve got things sort of working.

float myValue;

void setup(){

size (1200, 800);
background (0);
frameRate(15);

}

void draw(){
String[] time = loadStrings(“time.csv”);
String[] heart = loadStrings(“heart_rate.csv”);
String[] speed = loadStrings(“speed.csv”);

for (int i = 0; i < 120; i++){

myValue = 10 *( Float.valueOf(speed[i]).floatValue());
stroke(random(255), random(255), random(255), myValue * 3);
line(i * 10, i * 10, i * 10, i * 12);

}

for (int a = 0; a < 120; a++){

myValue = 10 *( Float.valueOf(time[a]).floatValue());
stroke(random(255), random(255), random(255), myValue * 3);
fill(random(255), random(255), random(255), myValue * 3);
ellipse(a * 10, myValue * 20, myValue * 5, myValue * 5);

}

}