1

I'm trying to scale a path in SVG. For doing so I'm using the javascript-library Raphaël. The scaling itself works just fine, but it's scaling at the center and I want it to scale at a different point (the figure of the path is a circle-sector and I want it to scale at the center of the "circle").

Is there a method to get the height and width of the path? if so, I'll be able to calculate the center of the circle. Or is there another method to find that point?

the path:

var path = "M "+center.x+" "+center.y;

path += "L "+(center.x+startX)+" "+(center.y+startY);

path += "A "+Math.floor(dist)+" "+Math.floor(dist)+" 0 " +(this.endAngle-this.startAngle > Math.PI ? "1 1 " :"0 1 ")+ (center.x+endX)+ " "+(center.y+endY);

path += "L "+center.x + " "+center.y; path += "z";

this.shape = paper.path(path);

4

1 回答 1

1

You can get the height and width of an element with .getBBox(): http://raphaeljs.com/reference.html#Element.getBBox

How are you scaling the path? .scale() can take optional coordinates for the center of scaling: http://raphaeljs.com/reference.html#Element.scale

于 2012-07-24T12:51:03.717 回答