/* * This program draws your arrangement of faces on the canvas. */ const canvasWidth = 960; const canvasHeight = 500; let curRandomSeed = 0; let lastSwapTime = 0; const millisPerSwap = 5000; function setup () { // create the drawing canvas, save the canvas element let main_canvas = createCanvas(canvasWidth, canvasHeight); main_canvas.parent('canvasContainer'); curRandomSeed = int(focusedRandom(0, 1000)); // rotation in degrees angleMode(DEGREES); } function changeRandomSeed() { curRandomSeed = curRandomSeed + 1; lastSwapTime = millis(); } // global variables for colors const bg_color1 = [225, 206, 187]; function mouseClicked() { changeRandomSeed(); } function draw () { if(millis() > lastSwapTime + millisPerSwap) { changeRandomSeed(); } // reset the random number generator each time draw is called resetFocusedRandom(curRandomSeed); // clear screen background(50); noStroke(); let faceWidth; let earSize, earDist; let faceColor; let gridWidth = 10; let gridHeight = 6; // draw a 5x3 grid of faces let w = canvasWidth / gridWidth; let h = canvasHeight / gridHeight; for(let i=0; i= 2 && faceColorSpinner <= 3) { faceColor = 1; } else if(faceColorSpinner >= 4 && faceColorSpinner <= 6) { faceColor = 2; } else if(faceColorSpinner == 7) { faceColor = 3; } else { faceColor = 4; } if(faceColor == 1) { earSize = focusedRandom(5, 20, 1); } else { earSize = focusedRandom(0, 8, 2); } earDist = focusedRandom(0, 10, 4); drawMickeyMouse(earSize, earDist, faceColor); pop(); } } } function keyTyped() { if (key == '!') { saveBlocksImages(); } else if (key == '@') { saveBlocksImages(true); } }