Hi @chenglou!
Thank you so much for creating this brilliant library! It’s really exciting to see how text can flow with such expressive control and a concise, elegant API design. I’m a toolmaker interested in data visualization and generative art. To make it easier to create text-based visualizations and generative pieces, I built an extension on top of Pretext called Charming Pretext. Here’s a quick example:
import * as cm from "charmingjs";
const layout = cm.layoutTextInPath({
text: "Hello, Charming Pretext! I love generative art!", // Filling the path with this text
path: cm.pathCircle(160, 160, 150), // Built a circle path.
fontSize: 12,
fontFamily: "Inter",
});
context.font = `${layout.fontSize}px ${layout.fontFamily}`;
context.textAlign = "center";
context.textBaseline = "middle";
for (const t of layout.texts) {
context.save();
context.translate(t.x, t.y);
context.rotate((t.angle * Math.PI) / 180);
context.fillText(t.text, 0, 0);
context.restore();
}
It essentially allows text to flow within arbitrary shapes defined by SVG paths. I’ve also created a few demos to explore its potential.
I’m not entirely sure if this is the best approach to implementing something like this, so I would really appreciate any feedback or suggestions you might have.
Thanks again for your inspiring work on this project!
Hi @chenglou!
Thank you so much for creating this brilliant library! It’s really exciting to see how text can flow with such expressive control and a concise, elegant API design. I’m a toolmaker interested in data visualization and generative art. To make it easier to create text-based visualizations and generative pieces, I built an extension on top of Pretext called Charming Pretext. Here’s a quick example:
It essentially allows text to flow within arbitrary shapes defined by SVG paths. I’ve also created a few demos to explore its potential.
I’m not entirely sure if this is the best approach to implementing something like this, so I would really appreciate any feedback or suggestions you might have.
Thanks again for your inspiring work on this project!