admin管理员组文章数量:1194568
I have seen several threads that adress this question but nothing that really solves my problem. I have a SVG file with a map and differrent regions. I want do do something like this: .html.
But the question is how I can convert the file so that is works in the script? How do I get those coordinates? I have tried several converters and such but I must suck at this 'cause I cant get it to work. Maybe someone can help out?
I have seen several threads that adress this question but nothing that really solves my problem. I have a SVG file with a map and differrent regions. I want do do something like this: http://raphaeljs.com/australia.html.
But the question is how I can convert the file so that is works in the script? How do I get those coordinates? I have tried several converters and such but I must suck at this 'cause I cant get it to work. Maybe someone can help out?
Share Improve this question edited Mar 5, 2024 at 17:13 General Grievance 4,99837 gold badges37 silver badges55 bronze badges asked Oct 28, 2011 at 8:06 larschanderslarschanders 1,9894 gold badges17 silver badges22 bronze badges 1- possible duplicate of SVG files in Raphael, can they be used? – Peter O. Commented Dec 7, 2012 at 16:14
3 Answers
Reset to default 10If 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 also SVG 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 rappar
var 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.
本文标签: javascriptRaphael JSUse a SVG fileStack Overflow
版权声明:本文标题:javascript - Raphael JS - Use a SVG file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738437724a2086773.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论