I submitted a post to do this, but it hasn't made it through
moderation (yet? ever?). It doesn't cover everything, but does quite a
lot. It also uses jQuery to make parts simpler. If you aren't
supporting IE, you can remove the parseXML function/reference and
change the $.get type from 'text' to 'xml':
function parseXML( xml ) {
if( window.ActiveXObject && window.GetObject ) {
var dom = new ActiveXObject( 'Microsoft.XMLDOM' );
dom.loadXML( xml );
return dom;
}
if( window.DOMParser )
return new DOMParser().parseFromString( xml, 'text/xml' );
throw new Error( 'No XML parser available' );
}
$(function(){
$.get('demo.svg', null, function(doc){ // or 'demo.svg'
doc = parseXML(doc);
var root = $(doc).find('svg')[0],
vb = root.getAttribute('viewBox'), dims = vb ? vb.split(' ') :
[0,0,root.getAttribute('width'),root.getAttribute('height')];
var img = Raphael(parseFloat(dims[0]), parseFloat(dims[1]),
parseFloat(dims[2]), parseFloat(dims[3]));
$(root).find('path').each(function(){
var node = this, path = img.path($(this).attr('d'));
$(['stroke-linejoin','stroke','stroke-miterlimit','stroke-
width','fill','stroke-linecap']).each(function(){
if($(node).attr(this.toString()))
path.attr(this, $(node).attr(this.toString()));
});
if($(node).attr('style')) {
var atts = $(node).attr('style').split(';');
for(var i=0;i<atts.length;i++) {
var bits = atts[i].split(':');
path.attr(bits[0],bits[1]);
}
}
/*path.scale(0.5, 0.5);
var box = path.getBBox(), x=box.x+box.width/2.0, y = box.y
+box.height/2.0;
path.translate(x*0.5-x, y*0.5-y);*/
});
}, 'text');
});
On Nov 10, 10:22 pm, Josepssv <
josep....@gmail.com> wrote:
> Completad SVG to OPF to Raphaeljshttp://
onlypaths.com/aaopblog/2009/11/7/