xxxxxxxxxx
var gB, fullRes, windowRes;
var requiredFrames = 120;
function setup() {
windowRes = min(windowWidth, windowHeight);
createCanvas(windowRes, windowRes);
imageMode(CENTER);
gB = createGraphics(fullRes = 1024, fullRes);
gB.colorMode(HSB, 360);
}
function draw() {
gB.clear();
gB.resetMatrix();
gB.translate(fullRes * 0.5, fullRes * 0.5);
gB.stroke(0);
gB.noFill();
var animationProgress = (frameCount / requiredFrames) % 1;
gB.ellipse(0, 0, map(cos(animationProgress * TAU), -1, 1, fullRes * 0.25, fullRes * 0.75));
background(360);
displayBuffer(gB);
}
function keyPressed() {
if (key === "g") {
saveGif('export', requiredFrames, {delay: 0, units: "frames"});
}
}
function displayBuffer(buffer) {
image(buffer, windowRes/2, windowRes/2, windowRes, windowRes);
}
function windowResized() {
windowRes = min(windowWidth, windowHeight);
createCanvas(windowRes, windowRes);
}