Is there a way to convert SVG files to HTML5's canvas compatible commands?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
There's no 100% solution, but there are script libraries that can convert a subset of svg to canvas, e.g http://code.google.com/p/canvas-svg/. There's also the experimental Path2D API that can draw an svg path data string onto the canvas, not sure how well it's supported across browsers though.
There is
Save as: HTML5 canvas
command in Inkscape (free software for vector graphic)https://inkscape.org/en/
You can expect results like this:
Source SVG file was like this:
It is not perfect, one line is missing at the bottom, you may have to fix that in code or draw SVG better (maybe my house shape path is not closed properly).
Had same requirement for a couple internal projects. Thought it might help others, so it's available as an SVG2Canvas experiment.
No. SVG is a (mostly) static vector format and canvas is an API to a dynamic bitmap. Turning SVG into canvas makes as much sense as turning SVG into MathML: none.
I recommend the Java project SVGToCanvas if you just want to statically generate some Canvas javascript from a SVG file.
try this:
http://www.professorcloud.com/svg-to-canvas/