xxxxxxxxxx
36
let numLines = 230; // Número de líneas o elementos en el torbellino
let maxRadius;
function setup() {
angleMode(DEGREES);
createCanvas(windowWidth, windowHeight);
maxRadius = min(width, height); // Radio máximo del torbellino
noFill();
stroke(199, 234, 70); // Color del torbellino
strokeWeight(1); // Grosor de las líneas
}
function draw() {
background(0); // Fondo negro
translate(width / 2, height / 2); // Mover origen al centro del canvas
let angleStep = 450 / numLines; // Paso del ángulo entre cada línea
let radiusStep = maxRadius / numLines; // Incremento del radio entre cada línea
for (let i = 0; i < numLines; i++) {
let angle = i * angleStep + frameCount * 1.7; // Ángulo con incremento para rotar
let radius = i * radiusStep; // Radio en aumento para el efecto espiral
// Coordenadas de las puntas de las líneas
let x1 = cos(angle) * radius;
let y1 = sin(angle) * radius;
let x2 = cos(angle + 90) * (radius + 360); // Un pequeño desplazamiento
let y2 = sin(angle + 90) * (radius + 10);
stroke(28 - i, 37 + i, 174 - i); // Cambiar el color gradualmente
line(x1, y1, x2, y2); // Dibujar la línea en el torbellino
}
}