xxxxxxxxxx
34
//createGraphics();
let x = 200;
let y = 200;
let extraCanvas;
function setup() {
createCanvas(400, 400);
extraCanvas = createGraphics(400, 400);
extraCanvas.clear();
background(0);
}
function draw() {
//no trails
background(0);
x += random(-5, 5);
y += random(-5, 5);
//trails
if(mouseIsPressed) {
extraCanvas.fill(255, 150);
extraCanvas.noStroke();
extraCanvas.circle(mouseX, mouseY, 24);
}
//moving the rect drawing down here allows it to be on top of our drawing trail
image(extraCanvas, 0, 0);
fill(255, 0, 0);
stroke(255);
rectMode(CENTER);
rect(x, y, 20, 20);
}