xxxxxxxxxx
33
let font;
function preload() {
font = loadFont('data/GloriaHallelujah-Regular.ttf');
}
let points;
let bounds;
function setup() {
createCanvas(500, 100);
noStroke();
fill("red");
points = font.textToPoints('Spooky', 0, 0, 10, {
sampleFactor: 5,
simplifyThreshold: 0
});
bounds = font.textBounds('Spooky', 0, 0, 10);
}
function draw() {
background(0);
beginShape();
translate(-bounds.x * width / bounds.w, -bounds.y * height / bounds.h);
for (let i = 0; i < points.length; i++) {
let p = points[i];
vertex(
p.x * width / bounds.w +
sin(10 * p.y / bounds.h + millis() / 300) * width / 30,
p.y * height / bounds.h
);
}
endShape(CLOSE);
}