xxxxxxxxxx
30
//creat 2 canvas. one for stars, the other one for floating square
let extraCanvas;
function setup() {
createCanvas(400, 400);
extraCanvas = createGraphics(400, 400);
extraCanvas.clear();
}
function draw() {
background(0); //是为了maincanvas
//extraCanvas
y = random(400);
z = random(400);
extraCanvas.fill(255, 0, 0);
extraCanvas.ellipse(y, z, 5, 5);
image(extraCanvas, 0, 0);
//main canvas
fill(255, 200, 0);
let x;
x = random(20, 50);
ellipse(200, 200, x);
}