Question

The default stroke for creating SVG elements with raphaeljs seems to be black 1px. I can manually turn it off every time I create an element, but I rather set it as a default attribute "stroke: none" to the entire paper. Is it possible?

Était-ce utile?

La solution

I encountered this problem a little while ago; I believe this is a library default. Whilst you could change this in your library source, doing so would make updating library versions difficult, so you might be better off disabling it in the code that calls Raphael.

If you're worried about this being verbose, you could use a delegate function that hides the 'defaulting hacks' as you build similar shapes.

Autres conseils

It depends if this is just for defaults, or trying to cut down repeated code etc. You could create your own shape with defaults you want as a possible alternative is what I was thinking...

var paper = Raphael('mydiv',400,400);

Raphael.fn.myBlueCircle = function (x,y,r) {
    this.circle(x,y,r).attr({fill: "#00f", stroke: "none"});
};

paper.myBlueCircle(100,100,100);
paper.myBlueCircle(150,200,100);

jsfiddle

You may also want to do the same for sets if those are to be used with the new elements reference

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top