xxxxxxxxxx
36
let mFont;
let mSize = 120;
let word = "word";
let wordPoints;
function preload() {
mFont = loadFont("./ostrich-sans-regular.ttf");
}
function setup() {
createCanvas(400, 400);
textFont(mFont);
textSize(mSize);
wordPoints = mFont.textToPoints(word, 0, 0, mSize, {
sampleFactor: 1,
});
noFill(0);
}
function draw() {
background(220, 20, 120);
let randMax = map(mouseY, 0, height, 0, 16);
translate((width - textWidth(word)) / 2, (height + mSize) / 2);
beginShape();
for (let i = 0; i < wordPoints.length; i++) {
let p = wordPoints[i];
let rx = random(-randMax, randMax);
let ry = random(-randMax, randMax);
vertex(p.x + rx, p.y + ry);
}
endShape();
}