xxxxxxxxxx
let font;
let points;
let wordList = ["心所向 持以恒"];
var pdf;
function setup() {
createCanvas(windowWidth, windowHeight, SVG);
let chosenWord = random(wordList);
points = getFontOutlinePointsForWord(chosenWord);
pdf = createPDF();
pdf.beginRecord();
}
function draw() {
background(50);
for (let i = 0; i < points.length; i++) {
let p = points[i];
let radius = 1;
circle(p.x, p.y, radius);
}
stroke(255);
fill(255);
if (frameCount == 10) {
noLoop();
pdf.save();
}
}
function preload() {
font = loadFont("Alibaba-PuHuiTi-Medium.ttf");
}
function getFontOutlinePointsForWord(word) {
return font.textToPoints(word, 100, height / 2, 200, {
sampleFactor: 0.5,
simplifyThreshold: 0
});
}