xxxxxxxxxx
58
let myriad;
let wordArray;
let mouseWidth = 0;
let widthValue = 0;
const fontSize = 200;
let sample = 0.1;
let letterWidth = 0;
function preload() {
myriad = loadFont('MyriadPro-Bold.otf');
}
function setup() {
createCanvas(600, 600);
textFont(myriad);
textSize(fontSize);
fill(180,10,10);
stroke(255, 255, 0);
strokeWeight(2);
}
function draw() {
background(200,100,200);
rect(0,0,width/2+35-mouseWidth*2, height);
if (mouseIsPressed) {
mouseWidth+=10;
}
else
{
if (mouseWidth > 0) {
mouseWidth-=10;
}
}
text('go', width / 2 - 80 + mouseWidth, height / 2 + 65);
widthValue-=10;
wordArray = myriad.textToPoints('go', width / 2 - 80 - mouseWidth, height / 2 + 65, fontSize, {
sampleFactor: sample
});
for (let i = 0; i < wordArray.length; i++) {
letterWidth = random(0,100);
rect(wordArray[i].x, wordArray[i].y, letterWidth, 5);
}
}