xxxxxxxxxx
42
let x = 0;
let y = 0;
function setup() {
createCanvas(400,400);
noStroke();
}
function draw() {
background('purple');
// lerp() calculates a number between two numbers at a specific increment.
// The amt parameter is the amount to interpolate between the two values
// where 0.0 equal to the first point, 0.1 is very near the first point, 0.5
// is half-way in between, etc.
// Here we are moving 5% of the way to the mouse location each frame
x = lerp(x, mouseX, 0.05);
y = lerp(y, mouseY, 0.06);
fill('black');
stroke(255);
ellipse(x, y, 66, 66);
strokeWeight(15);
point(mouseX, mouseY);
//if (test) {doThis; }
//test: mouseX on far left of canvas
//doThis: draw a circle at mouseY
if (mouseX < 10) {
circle(width / 2, mouseY, 20);
}
//test: mouseX on far right of canvas
//doThis: draw a square at mouseY
if (mouseX > width - 10) {
square(width / 2, mouseY, 20);
}
}