Just a noob question...
in
Programming Questions
•
2 years ago
Hi everyone, I'm just making my way through "Getting started with processing" and I've come across my first bump in the road:
float x;
float y;
float px;
float py;
float easing = 0.1;
void setup(){
frameRate(1);
size(1000,1500);
smooth();
stroke(0,102);
}
void draw(){
py=y;
px=x;
x += (mouseX - x) * easing;
y += (mouseY - y) * easing;
float weight = dist(x, y, px, py);
strokeWeight (weight);
line(x,y,px,py);
println (x+":"+px);
}
Its a pretty simple example demonstrating easing but I can't for the life of me understand why the variables "px" and "x" are different in value from each other (and "py" and "y" for that matter). Having slowed the frame rate right down and using "println" I can see that "px" is always equal to the previous frame value for "x", which seems logical considering the functionality of the patch, but what is making this happen?! The only place that I can see the value for "px" being defined is here:
px=x;
why then are they not just the same number? I know I'm missing something fundamental here, any help would be appreciated!
1