xxxxxxxxxx
94
let angle = 0;
let rectAngle = 0;
let spacing = 20;
let minRadius = 10;
let maxRadius = 100;
let numCircles = 5;
let loopRunning = true;
let colorList = [];
let lastColorChangeFrame = 0;
let colorChangeInterval = 180; // Change colors every 3 seconds
let bigColorList = [ // [[247, 8, 69],[248, 35, 89],[249, 62, 110],[250, 90, 131],[251, 145, 172],[253, 200, 214]], //color0
[[143, 87, 225],[157, 108, 228],[185, 150, 236],[199, 171, 240],[241, 234, 251]], //color1
[[8, 236, 255],[110, 242, 255],[159, 247, 255],[207, 251, 255]],//color3
[[65, 134, 38],[79, 163, 47],[94, 193, 55],[138, 213, 109],[162, 222, 138],[185, 230, 168]],//color2
[[248, 194, 35],[250, 209, 90],[251, 217, 117],[254, 247, 227]]
];
function setup() {
createCanvas(600, 500);
background(255);
noFill();
stroke(0);
colorList = bigColorList[1];
}
function draw() {
// check if it's time to change colors
if (frameCount - lastColorChangeFrame >= colorChangeInterval) {
lastColorChangeFrame = frameCount;
let randomColorIndex = int(random(bigColorList.length));
colorList = bigColorList[randomColorIndex];
// modify other parameters based on the selected color
if (randomColorIndex === 0) {
maxRadius = 50;
spacing = 80;
numCircles = 5;
minRadius = 30;
} else if (randomColorIndex === 1) {
maxRadius = 70;
spacing = 130;
numCircles = 5;
minRadius = 10;
} else if (randomColorIndex === 2) {
maxRadius = 70;
spacing = 160;
numCircles = 5;
minRadius = 5;
} else {
maxRadius = 70;
spacing = 180;
numCircles = 5;
minRadius = 20;
}
}
noFill();
stroke(random(colorList));
makeArt(maxRadius, spacing, numCircles, minRadius);
}
function makeArt(maxRadius, spacing, numCircles, minRadius) {
translate(width/2, height/2);
for (let i = 0; i < numCircles; i++) {
let x = cos(angle) * spacing * i;
let y = sin(angle) * spacing * i;
let radius = map(i, 0, numCircles, minRadius, maxRadius);
let outerRadius = maxRadius * 1.25;
rectMode(CENTER);
rotate(angle);
rect(0,0, outerRadius *2 , outerRadius * 2 );
push();
translate(x, y);
rotate(rectAngle);
ellipse(0, 0, radius);
pop();
}
angle += 0.01;
rectAngle += 0.31;
}
function mousePressed() {
noLoop();
}
function mouseReleased() {
loop();
}