xxxxxxxxxx
43
var p1, p2;
function setup() {
createCanvas(400, 400);
p1 = [];
p2 = [];
var radius = 100;
var sides = 10;
var stepSize = TWO_PI / sides;
var offset = 0;
var rotation = radians(90);
for(var i = 0; i < sides; i++) {
offset = random(0, 10) * 10;
p1.push({
x: offset + width / 2 + radius * cos(rotation + i * stepSize),
y: offset + height / 4 + radius * sin(rotation + i * stepSize)
});
}
for(var i = 0; i < sides; i++) {
offset = random(-5, 5) * 10;
p2.push({
x: offset + width / 2 + radius * cos(i * sides),
y: offset + height / 2 + radius * sin(i * sides)
});
}
}
function draw() {
background(220);
for(var i = 0; i < p1.length; i++) {
line(p1[i].x, p1[i].y, p1[(i + 1) % p1.length].x, p1[(i + 1) % p1.length].y);
}
/*
for(var i = 0; i < p1.length; i++) {
line(p1[i].x, height / 2 + p1[i].y, p1[(i + 1) % p1.length].x, height / 2 + p1[(i + 1) % p1.length].y);
}*/
}