xxxxxxxxxx
105
// 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 C by RICHARD OO";
let fontSize = 400
let akira;
let hiArray;
let twoarray;
function preload(){
akira = loadFont ('assets/Akira Expanded Demo.otf');
}
function setup() {
// if you add SVG as 3rd parameter and then
// press s, the canvas will be saved as SVG file
createCanvas(1080, 1080);
textFont(akira);
textSize(fontSize)
// createCanvas(540, 540, SVG);
hiArray =
akira.textToPoints("C",350,600,fontSize, {
sampleFactor: 0.14
});
twoArray =
akira.textToPoints("i",90,400,fontSize, {
sampleFactor: 0.2
});
}
function draw() {
let v0 = map(sin(frameCount*0.060),-1,1,10,40);
let v1 = map(sin(frameCount*0.020),-1,1,5,25);
let v2 = map(sin(frameCount*0.020),-1,1,20,80);
background('#151618');
//text ("C", width/2, height/2);
for (let i = 0; i <hiArray.length;i++){
push();
translate(hiArray[i].x, hiArray[i].y);
stroke('#cdff00');
strokeWeight(3);
{line(-10,v2,v0,v1);
pop();
}
}
c = color('#cdff00');
fill(c);
noStroke();
//for (let i = 0; i <twoArray.length;i++){
//push();
// translate(twoArray[i].x, twoArray[i].y);
// stroke('black');
// strokeWeight(3);
// {line(-10,-10,v0,v1);
// 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");
}
}
}