A class built for importing SVGs into Happycode. Imports an SVG string to a DOM element or an HTML canvas. Handles some of the quirks with Happycode 2.0 SVGs, which sometimes misreport their width, height and view box.
This requires you to have Git and Node.js installed.
To install as a dependency for your own application:
npm install happycode-svg-renderer
To set up a development environment to edit happycode-svg-renderer yourself:
git clone https://gitee.com/happycoding-cx/happycode-svg-renderer.git
cd happycode-svg-renderer
npm install
import SvgRenderer from 'happycode-svg-renderer';
const svgRenderer = new SvgRenderer();
const svgData = "<svg>...</svg>";
const scale = 1;
const quirksMode = false; // If true, emulate Happycode 2.0 SVG rendering "quirks"
function doSomethingWith(canvas) {...};
svgRenderer.loadSVG(svgData, quirksMode, () => {
svgRenderer.draw(scale);
doSomethingWith(svgRenderer.canvas);
});
To run happycode-svg-renderer locally as part of happycode-gui, for development:
- Set up local repositories (or pull updated code):
- happycode-svg-renderer (this repo)
- happycode-render
- happycode-paint
- happycode-gui
- In each of the local repos above, run
npm install
- Run
npm link
in each of these local repos:- happycode-svg-renderer
- happycode-render
- happycode-paint
- Run
npm link happycode-svg-renderer
in each of these local repos:- happycode-render
- happycode-paint
- happycode-gui
- In your local happycode-gui repo:
- run
npm link happycode-render
- run
npm link happycode-paint
- run
- In happycode-gui, follow its instructions to run it or build its code
We provide Happycode free of charge, and want to keep it that way! Please consider making a donation to support our continued engineering, design, community, and resource development efforts. Donations of any size are appreciated. Thank you!