xxxxxxxxxx
53
// 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 = "Letter-V-Sketch";
function setup() {
// if you add SVG as 3rd parameter and then
// press s, the canvas will be saved as SVG file
createCanvas(600, 850);
// createCanvas(540, 540, SVG);
}
function draw() {
background(0);
noStroke();
fill(255,105,180);
push();
translate(230,550);
rotate(-PI*0.75);
rect(0,0,500,100);
pop();
for (let i = 0; i < 60; i++) {
push();
translate(i*10*tan(frameCount*0.01),i*0.2);
rotate(-PI*0.75);
rect(-550,-200,2,500-i);
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");
}
}
}