xxxxxxxxxx
41
const r = 20
const numPoints = 10
const points = []
function setup() {
createCanvas(400, 400);
noLoop()
}
function draw() {
background(220);
circle(width / 2, height / 2, r * 2)
// beginShape();
//
// let prev = false
for (let i = 0; i <= 360; i += 360 / numPoints) {
let dis = random(30, 50)
const y = dis * sin(i)
const x = dis * cos(i)
// if (prev) {
// line(width/2 + prev[0], height /2 + prev[1], width / 2 + x, height / 2 + y)
// }
// prev = [x, y]
// vertex(width / 2 + x, height / 2 + y);
ellipse(width / 2 + x, height / 2 + y, r /2)
points.push([width / 2 + x, height / 2 + y])
}
points.forEach((point, i) => {
if (points[i + i])
line(point[0], point[1], points[i + 1][0], points[i + 1][1])
})
// endShape(CLOSE);
}