Adding values, more graphs
in
Programming Questions
•
1 year ago
Dear all interested readers,
I am trying to visualise actual data. I have made a moving graph, like a heart monitor. What would be the best way to add more values in order to make more graphs? Maybe I can make a class for it, or can I do this more simple?
Example of what I want to do:
Thanks in advance,
Joshua
I am trying to visualise actual data. I have made a moving graph, like a heart monitor. What would be the best way to add more values in order to make more graphs? Maybe I can make a class for it, or can I do this more simple?
- float[] values;
int numPoints;
void setup(){
size(800,600);
frameRate(30);
smooth();
noStroke();
frame.setResizable(true);
numPoints = 20;
values = new float[numPoints];
}
void draw(){
background(255);
if (frameCount % 10 == 0) {
storeval();
}
values[0] = (height*0.01)*(mouseX);
fill(100,250,100,150);
beginShape();
for (int i=0; i<numPoints; i++) {
float value = values[i];
float x = width - (width / numPoints) * i;
float y = height - value;
vertex(x, y);
}
vertex(0, height);
vertex(width, height);
endShape();
}
void storeval(){
for(int i = numPoints-2; i >= 0; i--){
values[i+1] = values[i];
}
}
Example of what I want to do:
Thanks in advance,
Joshua
1