@thi.ng/hiccup-canvas
Version:
Hiccup shape tree renderer for vanilla Canvas 2D contexts
13 lines (12 loc) • 307 B
JavaScript
const text = (ctx, attribs, pos, body, maxWidth) => {
let v;
if ((v = attribs.fill) && v !== "none") {
ctx.fillText(body.toString(), pos[0], pos[1], maxWidth);
}
if ((v = attribs.stroke) && v !== "none") {
ctx.strokeText(body.toString(), pos[0], pos[1], maxWidth);
}
};
export {
text
};