xxxxxxxxxx
48
let r1;
let r2;
let increment1;
let increment2;
let a1;
let a2;
function setup() {
createCanvas(windowWidth, windowHeight);
angleMode(DEGREES);
r1 = random(100, 500); // Random radius 1
r2 = random(50, 100); // Random radius 2
increment1 = random(0.1, 5); // Random angle increment for a1
increment2 = random(0.1, 5); // Random angle increment for a2
a1 = 10; // Initialize angle a1
a2 = 10; // Initialize angle a2
}
function draw() {
stroke(255);
strokeWeight(0.6);
background(30);
frameRate(5)
for (let i = 0; i <= 20000; i+=90) {
// Calculate positions based on the angles
let x1 = width / 2 + r1 * cos(a1);
let y1 = height / 2 + r1 * sin(a1);
let x2 = x1 + r2 * cos(a2);
let y2 = y1 + r2 * sin(a2);
// Draw the line between the two points
line(x1, y1, x2, y2);
// Increment the angles
a1 += increment1;
a2 += increment2;
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight); // Adjust canvas when window size changes
}