I'm following the getting started with processing book. and there s a piece code I can't quite wrap my head around.
- float x;
- float y;
- float px;
- float py;
- float easing = 0.05;
- void setup() {
- size(480, 480);
- smooth();
- stroke(0, 102);
- }
- void draw() {
- py = y;
- px = x;
- float targetX = mouseX;
- x += (targetX - x) * easing;
- float targetY = mouseY;
- y += (targetY - y) * easing;
- float dia = dist(x, y, px, py);
- ellipse(x, y, dia, dia);
- println(x + ":" + px);
- }
first if py = y and px = x shouldn't they be identical? why are they returning different values?
second, what's the purpose declaring targetX and targetY? why can't I just use mouseX and mouseY?
this is my first time learning to code, so please help me out.
Thank You!
1