xxxxxxxxxx
71
// 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";
let x;
let x1;
let x2;
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(100,100)
shape();
let a = frameCount*0.04
x = sin(frameCount*0.04)
x1 = map(x,-1,1,0,50)
x2 = map(x,-1,1,0,-50)
}
function shape() {
rectMode(CENTER);
push();
translate(250,120);
for (let i = 0; i < 4; i++) {
translate(x1,i+58)
triangle(75,30, 20, 60, 75, 90);
}
/*triangle(75, 30, 20, 60, 75, 90);*/
pop();
push();
translate(195,150);
for (let i = 0; i < 4; i++) {
translate(x2,i+58)
triangle(75,30, 130, 60, 75, 90);
}
/*triangle(75, 30, 20, 60, 75, 90);*/
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");
}
}
}