xxxxxxxxxx
36
let r;
let factor = 1;
function setup() {
createCanvas(windowWidth, windowHeight);
r = height / 2 - 15;
}
function getVector(index, total) {
const angle = map(index % total, 0, total, 0, TWO_PI);
const v = p5.Vector.fromAngle(angle + PI);
v.mult(r);
return v;
}
function draw() {
background("rgb(7,7,7)");
const total = 200; //int(map(mouseX, 0, width, 0, 200));
factor += 0.015;
translate(width / 2, height / 2);
stroke(255, 150);
strokeWeight(0);
noFill(0);
ellipse(0, 0, r * 2);
strokeWeight(1);
stroke("rgb(160,230,248)");
for (let i = 0; i < total; i++) {
const a = getVector(i, total);
const b = getVector(i * factor, total);
line(a.x, a.y, b.x, b.y);
}
}