xxxxxxxxxx
54
function setup() {
createCanvas(8 * 96, 10 * 96, SVG);
// background("white");
angleMode(DEGREES);
translate(width / 2, height / 2);
noFill();
stroke("black");
strokeWeight(2);
circle(0, 0, 10);
circle(0, 0, 20);
circle(0, 0, 50);
circle(0, 0, 40);
circle(0, 0, 30);
numberSpokes = Math.floor(random(4, 15));
// numberSpokes = 1;
// console.log(numberSpokes);
x1 = -50;
y1 = 230;
x2 = 64;
y2 = 330;
x3 = 135;
y3 = 190;
cx1 = (x1 + x2 + x3) / 3;
cy1 = (y1 + y2 + y3) / 3;
for (let s = 0; s < numberSpokes; s++) {
rotate(360 / numberSpokes);
line(0, 0, 50, 250);
for (let s = 0.9; s > 0.1; s -= 0.1) {
// triangle(-50 + c, 230 + c, 64 - c, 330 - c, 135 - c, 190 - c);
nx1 = s * (x1 - cx1) + cx1;
ny1 = s * (y1 - cy1) + cy1;
nx2 = s * (x2 - cx1) + cx1;
ny2 = s * (y2 - cy1) + cy1;
nx3 = s * (x3 - cx1) + cx1;
ny3 = s * (y3 - cy1) + cy1;
triangle(nx1, ny1, nx2, ny2, nx3, ny3);
}
triangle(x1, y1, x2, y2, x3, y3);
}
}
function mousePressed(){
save("spokes and triangles.svg");
}