@jsrob/svg-canvas
v0.1.0
Published
Forked from [`red-agate-svg-canvas`](https://github.com/shellyln/red-agate/tree/master/packages/red-agate-svg-canvas)
Downloads
178
Readme
svg-canvas
Forked from red-agate-svg-canvas
Changes in this fork
- ESM by default.
- Ships ESM and CJS bundles.
- Conventional Commits by default.
import { Rect2D, SvgCanvas } from '@jsrob/svg-canvas';
const canvasCtx = new SvgCanvas();
// You can call HTML5 Canvas APIs.
// See also: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API
canvasCtx.fillRect(10, 10, 80, 180);
// Render as SVG.
const svgString = canvasCtx.render(new Rect2D(0, 0 , 100, 200), 'mm');
// //Render as data URL encoded SVG.
// const svgDataUrl = canvasCtx.toDataUrl(new Rect2D(0, 0 , 100, 200), 'mm');
console.log(svgString);