Hi all,
I’m trying to make a simple, EKG-like graph.
As a first attempt, I’d like to plot mouseY vs. time. I’d like the graph to progress left-to-right, and then restart on the left side of the screen.
My graph right now only draws a small dot (as if it was constantly drawing a segment, then erasing.) Here is the main chunk of code. I gutted the graphics example for a framework.
Why does this code only draw a small red segment instead of constantly adding to a line? I’m coming from Processing, so I may be misinformed about how things are drawn and updated on the screen.
void testApp::draw(){
if (i < ofGetScreenWidth() ) {
currentTime = ofGetElapsedTimeMillis();
if ((currentTime - startTime) > 10) {
ofSetLineWidth(5);
ofSetHexColor(0xFF0000);
ofLine(i,mouseDy, i+10, mouseY);
mouseDy = mouseY;
startTime = ofGetElapsedTimeMillis();
i++;
}
}
else {
ofBackground(255,255,255);
startTime = ofGetElapsedTimeMillis();
currentTime = ofGetElapsedTimeMillis();
i = 0;
}
}