var gB, fullRes, windowRes;
var requiredFrames = 360;
var notAGridXDimension, notAGridYDimension, renderFrame, font;
windowRes = min(windowWidth, windowHeight);
createCanvas(windowRes, windowRes);
gB = createGraphics(fullRes = 2048, fullRes);
font = loadFont('LaBelleAurore-Regular.ttf');
renderFrame = frameCount + 1;
notAGridXDimension = 2 + floor(random(8));
notAGridYDimension = 2 + floor(random(8));
function randPow(multiplier, min, max, power) {
for (var i = 0; i < power; i += 1) {
multiplier *= random(min, max);
if (renderFrame === frameCount || frameCount === 1) {
gB.translate(fullRes * 0.5, fullRes * 0.4);
var notAGridSizeX = fullRes * 0.5 / notAGridXDimension - 16;
var notAGridSizeY = fullRes * 0.5 / notAGridYDimension - 16;
for (var i = 0; i < notAGridXDimension + 1; i += 1) {
for (var j = 0; j < notAGridYDimension + 1; j += 1) {
gB.translate(notAGridSizeX * 0.5, notAGridSizeY * 0.5);
gB.rotate(i * j * 0.01 * random(-1, 1) * randPow(1, 2));
gB.translate(notAGridSizeX * -0.5, notAGridSizeY * -0.5);
gB.rect(map(i, 0, notAGridXDimension, fullRes * -0.25, fullRes * 0.25), map(j, 0, notAGridYDimension, fullRes * -0.25, fullRes * 0.25), notAGridSizeX, notAGridSizeY);
gB.textAlign(CENTER, CENTER);
gB.text("Ceci n'est pas une grille", 0, fullRes * 0.425);
function mouseClicked() {
saveGif('export', requiredFrames, {
function displayBuffer(buffer) {
image(buffer, windowRes / 2, windowRes / 2, windowRes, windowRes);
function windowResized() {
windowRes = min(windowWidth, windowHeight);
resizeCanvas(windowRes, windowRes);