xxxxxxxxxx
74
// 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 = "f";
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,0,0);
noStroke();
fill(0);
push();
translate(30,-10);
scale(0.6);
//F
beginShape();
vertex(500,300);
vertex(400,300);
vertex(400,400);
vertex(600,400);
vertex(500,500);
vertex(400,500);
vertex(400,800);
vertex(300,800);
vertex(300,500);
vertex(200,500);
vertex(300,400);
vertex(300,300);
vertex(400,200);
vertex(600,200);
endShape();
//CURVE
beginShape();
curveVertex(600,300);
curveVertex(600,200);
curveVertex(500,300);
curveVertex(600,600);
endShape();
//CIRCLE
push();
ellipse(600,300,120);
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");
}
}
}