Files
sunny9898/task8/wk7/wk7_example1c/wk7_example1c.pde
louiscklaw 5637fbf94f update,
2025-02-01 02:07:58 +08:00

25 lines
395 B
Plaintext

float x = 0, y = 0;
void setup() {
size(400, 400);
noStroke();
}
void draw() {
background(230, 24);
// follow the mouse naturally
x = lerp(x, mouseX, .05);
y = lerp(y, mouseY, .05);
// change the color of the circle as it is near the mouse
float d = dist(x, y, mouseX, mouseY);
if (d < 10) {
fill(200, 0, 0);
} else {
fill(255);
}
ellipse(x, y, 30, 30);
}