UNPKG

@thi.ng/hiccup-canvas

Version:

Hiccup shape tree renderer for vanilla Canvas 2D contexts

21 lines (20 loc) 418 B
const line = (ctx, attribs, a, b) => { if (attribs.stroke === "none") return; ctx.beginPath(); ctx.moveTo(a[0], a[1]); ctx.lineTo(b[0], b[1]); ctx.stroke(); }; const lines = (ctx, attribs, pairs) => { if (attribs.stroke === "none") return; ctx.beginPath(); for (const { 0: a, 1: b } of pairs) { ctx.moveTo(a[0], a[1]); ctx.lineTo(b[0], b[1]); } ctx.stroke(); }; export { line, lines };