Mouse-click to re-roll parameters; 'g' to render a small gif
xxxxxxxxxx
var gB, fullRes, windowRes;
var requiredFrames = 120;
var numberOfCircles= 12;
var symmetry, numberOfCircles, minSize, maxSize, plotRadius;
function setup() {
windowRes = min(windowWidth, windowHeight);
createCanvas(windowRes, windowRes);
imageMode(CENTER);
gB = createGraphics(fullRes = 1024, fullRes);
gB.colorMode(HSB, 360);
gB.blendMode(DIFFERENCE);
numberOfCircles = floor(random(3, 16));
symmetry = floor(random(3, 9));
plotRadius = random() * random() * random();
minSize = random(0.5) * random();
maxSize = 1 - random(0.5) * random();
}
function draw() {
gB.clear();
gB.resetMatrix();
gB.translate(fullRes * 0.5, fullRes * 0.5);
gB.fill(360);
gB.noStroke();
var animationProgress = (frameCount / requiredFrames) % 1;
for (var i = 0; i < numberOfCircles; i += 1) {
var theta = TAU / numberOfCircles * i;
gB.ellipse(fullRes * plotRadius * cos(theta), fullRes * plotRadius * sin(theta), map(cos(animationProgress * TAU + theta * symmetry), -1, 1, fullRes * minSize, fullRes * maxSize));
}
background(360);
displayBuffer(gB);
}
function mouseClicked() {
numberOfCircles = floor(random(3, 16));
symmetry = floor(random(3, 9));
plotRadius = random() * random() * random();
minSize = random(0.5) * random();
maxSize = 1 - random(0.5) * random();
}
function keyPressed() {
if (key === "g") {
windowRes = 512;
resizeCanvas(512, 512);
saveGif('export', requiredFrames, {delay: 0, units: "frames"});
}
}
function displayBuffer(buffer) {
image(buffer, windowRes/2, windowRes/2, windowRes, windowRes);
}
function windowResized() {
windowRes = min(windowWidth, windowHeight);
resizeCanvas(windowRes, windowRes);
}