xxxxxxxxxx
60
// 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-P-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);
push();
translate(250, 300);
for (let i = 0; i < 15; i++) {
push();
let v = tan(frameCount * 0.005);
// add a comment here
rotate(PI / 100);
translate(i * 2, i * 0.1 + v * 0);
rotate(v * i * 0.5);
let y =10 + v * 0;
fill(0,80,250,70);
noStroke();
circle(-60, 0, 220);
pop();
push();
translate(-190,-130);
fill(0,80,250);
noStroke();
rect(0,0,170,490,300);
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");
}
}
}
}