study/p5js/setup.js
2022-12-18 15:56:32 +08:00

22 lines
677 B
JavaScript

const circles = [
{ x: 100, y: 100, color: "red", size: 40 },
{ x: 200, y: 100, color: "orange", size: 40 },
{ x: 300, y: 100, color: "yellow", size: 40 },
{ x: 100, y: 200, color: "green", size: 40 },
{ x: 200, y: 200, color: "cyan", size: 40 },
{ x: 300, y: 200, color: "blue", size: 40 },
{ x: 100, y: 300, color: "purple", size: 40 },
{ x: 200, y: 300, color: "gray", size: 40 },
{ x: 300, y: 300, color: "black", size: 40 },
];
function setup() {
createCanvas(400, 400);
background(255);
circles.forEach((c) => {
strokeWeight(2);
stroke(0);
fill(c.color);
circle(c.x, c.y, c.size);
});
}