xxxxxxxxxx
21
function setup() {
createCanvas(400, 400);
background(220);
translate(width/2, height/2)
drawPolygon(0, 0, 150, int(Math.random()*10 + 3))
drawPolygon(0, 0, Math.random()*150, int(Math.random()*5 + 3))
}
function draw() {
}
function drawPolygon(cx, cy, radius, numSides) {
beginShape()
for (let angle = 0; angle < TWO_PI; angle += TWO_PI / numSides) {
let x = cx + radius * cos(angle)
let y = cy + radius * sin(angle)
vertex(x, y)
}
endShape(CLOSE)
}