xxxxxxxxxx
63
// 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(540, 540);
// createCanvas(540, 540, SVG);
}
function draw() {
background(255);
noStroke();
fill(0);
// L
push();
translate(50,50);
push();
for(let i=0;i<100;i++) {
push();
translate(0,i*3);
rotate(sin(i*0.02))
rect(0,0,200-i,1);
pop();
}
pop();
push();
translate(0,380)
rotate(-HALF_PI);
for(let i=0;i<120;i++) {
push();
translate(0,i*3);
rotate(sin(i*0.03))
rect(0,0,100,1);
pop();
}
pop();
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");
}
}
}