Raphael JS - Use a SVG file Raphael JS - Use a SVG file javascript javascript

Raphael JS - Use a SVG file


If you mean using Raphael to import an SVG file so you can display it or manipulate it, it's not currently supported. But you might want to check extensions raphael-svg-import or raphael-svg-import-classic.

See alsoSVG files in Raphael, can they be used?


Look at the code of:

http://raphaeljs.com/tiger.html

<script src="tiger.js">// Load the file with the tiger mapping to a variable     var tiger = [0,0,600,600,{type:"path",path:"M-122.304 84.285C-12...</script><script> // run it window.onload = function () {    var r = Raphael(tiger).translate(200, 200); };</script>


Additionally to mikefrey's answer using rapper, an example:

var paper = Raphael(0, 0, 160, 600);var rappar = [...]; // here use the output from rapparvar graphic = paper.set();rappar.forEach(function (item) {  graphic.push(paper    .path(item.path)    .attr('fill', item.fill)    .attr('stroke', item.stroke)    // ...  );});graphic.transform('s0.8,0.8,0,0');// ...

Using Raphael v2.2.6 and rappar v0.0.2.