xxxxxxxxxx
37
let r;
let factor = 0;
function setup() {
createCanvas(windowWidth - 20, windowHeight - 20);
r = height / 2 - 16;
}
function getVector(index, total) {
const angle = map(index, 0, total, 0, TWO_PI);
const v = p5.Vector.fromAngle(angle + PI);
v.mult(r);
v.angle = angle;
return v;
}
function draw() {
background(0);
colorMode(HSB);
const total = 200; //int(map(mouseX, 0, width, 0, 200));
factor += 0.015;
translate(width / 2, height / 2);
stroke(255, 150);
strokeWeight(2);
noFill();
ellipse(0, 0, r * 2);
strokeWeight(2);
for (let i = 0; i < total; i++) {
const a = getVector(i, total);
const b = getVector(i * factor, total);
const hue = map(b.angle, 0, TWO_PI, 0, 255);
fill(hue, 255, 255);
line(a.x, a.y, b.x, b.y);
}
}