xxxxxxxxxx
57
let angles = [];
let changeDirection = false;
function setup() {
createCanvas(500, 500);
noFill();
strokeWeight(10);
noCursor();
// Initialize angles array with random values
for (let x = 0; x < 20; x++) {
angles.push(random(PI));
}
}
function draw() {
background(0);
translate(width/2, height/2);
for (let x = 0; x < 20; x++) {
let radius = (10) * (x + 1);
let angle = angles[x];
// Set stroke color based on direction
if (changeDirection) {
stroke(random(200,255), random(200), random(150));
} else {
stroke(random(0), random(80,100), random(180,255));
}
noFill();
arc(0, 0, radius * 2, radius * 2, PI / 4 + angle, 3 * PI / 4 + angle);
arc(0, 0, radius * 2, radius * 2, -3 * PI / 4 + angle, -PI / 4 + angle);
if (changeDirection) {
if (x % 2 == 0) {
angles[x] -= 0.1;
} else {
angles[x] += 0.1;
}
} else {
if (x % 2 == 0) {
angles[x] += 0.01;
} else {
angles[x] -= 0.01;
}
}
}
textSize(50);
text('🎶', mouseX - width/2, mouseY - height/2);
}
function mousePressed() {
changeDirection = !changeDirection;
}