RedAgate's SVG Canvas library.
HTML5 Canvas API implementation that rendering as SVG, w/o dependencies of browser DOM.
Install
$ npm install red-agate-util --save$ npm install red-agate-svg-canvas --save
Note
To import this from your code, you need to use
babel
+webpack
and importred-agate-*/modules/*
paths.
(We have used theimport
statements for doing the tree-shaking. Theimport
statements in the.js
not the.mjs
files cannot import from the vanilla node.js.)You can also import from the
.mjs
file on a node with the--experimental-modules
option enabled.
NOTICE:
Use withwebpack >= 5
If you get the error:
Module not found: Error: Can't resolve '(importing/path/to/filename)' in '(path/to/node_modules/path/to/dirname)' Did you mean '(filename).js'?`
Add following setting to your
webpack.config.js
.test: /\.m?js/resolve:fullySpecified: falseOn
webpack >= 5
, the extension in the request is mandatory for it to be fully specified if the origin is a '.mjs' file or a '.js' file where the package.json contains '"type": "module"'.
Usage
;; ; // You can call HTML5 Canvas APIs.// See also: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_APIcanvasCtx.fillRect10, 10, 80, 180; // Render as SVG.; // //Render as data URL encoded SVG.// const svgDataUrl = canvasCtx.toDataUrl(new Rect2D(0, 0 , 100, 200), 'mm'); console.logsvgString;
Chart.js
Use with theSee this example.
Patch font rendering output for your target apps/libs' incompatibilities
;
See also:
- Issue #1
License
ISC
Copyright (c) 2017, Shellyl_N and Authors.