craftyjs / Crafty

JavaScript Game Engine
http://craftyjs.com
MIT License
3.42k stars 556 forks source link

SVG render engine support #1038

Open ghost opened 8 years ago

ghost commented 8 years ago

Hello. I suggest to add SVG engine to Crafty. For example, Raphael. I also asked, "why no polygon in Raphael?"... I also looked to svg.js, but they have another syntax, not like Crafty.

I thinking about:

var canvas = Crafty.init(100, 100, svgElement, "yes, it is SVG!");
var entity = canvas.e("SVGGroup");
entity.svg.add(shapeNode); //Specific function for adding subnodes
var subnode = entity.svg.rect(-10, -10, 20, 20).attr({fill: "#FF0000"}); //Standard SVG engine functions
entity.attr({x: 10, y: 10, scaleX: 0.5, scaleY: 0.5}); //Entity are SVG group, so behaviour like this
matthijsgroen commented 8 years ago

If another render engine would be added, I would prefer to have the same functionality as the others, so that DOM, SVG, Canvas and WebGL are as interchangeable as possible.

starwed commented 8 years ago

If another render engine would be added, I would prefer to have the same functionality as the others, so that DOM, SVG, Canvas and WebGL are as interchangeable as possible.

I agree this would be the case for built-in layers, but I think we're now at a point where additional layers could be implemented just as easily by external scripts. That would probably be the best way forward for pulling in additional libraries such as Raphael.