UNPKG

@thi.ng/hiccup-canvas

Version:

Hiccup shape tree renderer for vanilla Canvas 2D contexts

20 lines (19 loc) 457 B
import { __endShape } from "./internal/end-shape.js"; const rect = (ctx, attribs, pos, w, h, radii) => { let v; if (radii !== void 0) { ctx.beginPath(); ctx.roundRect(pos[0], pos[1], w, h, radii); __endShape(ctx, attribs); return; } if ((v = attribs.fill) && v !== "none") { ctx.fillRect(pos[0], pos[1], w, h); } if ((v = attribs.stroke) && v !== "none") { ctx.strokeRect(pos[0], pos[1], w, h); } }; export { rect };