xxxxxxxxxx
132
// code template for
// https://slides.com/sojamo/generative-type-l2-2021/fullscreen
// press s after activating the canvas
// (press mouse inside canvas) to save
// canvas to svg or png depending on the
// renderer selected.
let label = "your-label-here";
function setup() {
// if you add SVG as 3rd parameter and then
// press s, the canvas will be saved as SVG file
createCanvas(800, 800);
// createCanvas(540, 540, SVG);
}
function draw() {
background(255,15);
noStroke();
fill(0);
translate(150,100)
shape();
}
function shape() {
rectMode(CENTER);
push();
translate(100,460);
rotate(PI*0.50 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(110,390);
rotate(PI* 1 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(140,390);
rotate(PI* 1 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(150,320);
rotate(PI*0.50 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(160,250);
rotate(PI* 1 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(190,250);
rotate(PI* 1 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(250,180);
rotate(PI*0.50 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(250,150);
rotate(PI*0.50 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(310,250);
rotate(PI* -1 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(340,250);
rotate(PI* -1 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(350,320);
rotate(PI* -0.50 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(390,390);
rotate(PI* -1 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(360,390);
rotate(PI* -1 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
push();
translate(400,460);
rotate(PI* -0.50 * cos(frameCount*0.01));
rect(0,0,20,100);
pop();
}
// if you want to use the SVG export
// option, go to setup and enable SVG mode
// no need to make any changes below.
function keyPressed() {
if (key === "s") {
if(this._renderer.elt.svg !== undefined) {
saveSVG(label + ".svg");
} else {
saveCanvas(label + ".png");
}
}
}