xxxxxxxxxx
var gB, fullRes, windowRes;
var requiredFrames = 360;
function setup() {
windowRes = min(windowWidth, windowHeight);
createCanvas(windowRes, windowRes);
imageMode(CENTER);
gB = createGraphics(fullRes = 1024, fullRes);
gB.colorMode(HSB, 360);
gB.rectMode(CENTER);
gB.fill(360);
}
function draw() {
gB.clear();
gB.resetMatrix();
gB.stroke(0);
gB.strokeWeight(8);
gB.translate(fullRes * 0.5, fullRes * 0.5);
gB.rect(0, 0, 200, 100);
background(360);
displayBuffer(gB);
}
function keyPressed() {
if (key === "r") {
windowRes = 512;
resizeCanvas(512, 512);
saveGif('export', requiredFrames, {
delay: 0,
units: "frames"
});
}
if (key === "s") {
saveCanvas();
}
}
function displayBuffer(buffer) {
image(buffer, windowRes / 2, windowRes / 2, windowRes, windowRes);
}
function windowResized() {
windowRes = min(windowWidth, windowHeight);
resizeCanvas(windowRes, windowRes);
}