xxxxxxxxxx
43
let font, pts;
function preload() {
font = loadFont('LEMONMILK-Bold.otf')
}
function setup() {
createCanvas(400, 400);
textFont(font);
textSize(100);
textAlign(CENTER, CENTER);
pts = font.textToPoints("test", 0, 0, 100, {
sampleFactor: 0.1, // increase for more points
simplifyThreshold: 0.0 // increase to remove collinear points
});
stroke(255)
strokeWeight(2)
noFill();
}
function draw() {
background(0)
// 1. interactive
const d = dist(mouseX, mouseY, width/2, height/2)
const angle = atan2(mouseY-height/2, mouseX-width/2)
// 2. animate on its own
//const d = 10 + sin(frameCount/50.) * 50
//const angle = frameCount/100.
push()
translate(60, height*5/8)
for (let i = 0; i < pts.length; i++) {
const p = pts[i]
push()
translate(p.x, p.y)
rotate(angle)
line(-d, -d, +d, +d)
pop()
}
pop()
}