xxxxxxxxxx
51
// Interactive Typography, vertecies length demo, Xin Xin, 2020
let grotesk;
const fontSize = 200;
let sample = 0.1;
function preload() {
grotesk = loadFont('Grotesk_Bold.otf');
}
function setup() {
createCanvas(400, 400);
textFont(grotesk);
textSize(fontSize);
fill(180);
stroke(255, 255, 0);
strokeWeight(1);
}
function draw() {
background(200);
let hiArray = grotesk.textToPoints('hi', width / 2 - 80, height / 2 + 65, fontSize, {
sampleFactor: sample
});
// print(hiArray);
print(hiArray.length);
for (let i = 0; i < hiArray.length; i++) {
ellipse(hiArray[i].x, hiArray[i].y, 10, 10);
}
textSize(20);
text("there are " + hiArray.length + " vertecies in this word", 60, 350);
}
function keyPressed(){
if (keyCode === UP_ARROW) {
sample+=0.01;
} else if (keyCode === DOWN_ARROW) {
sample-=0.01;
}
}