raphael
raphael copied to clipboard
Feature Request: after transform, can getPath() also return transformed path?
Example: var circle = paper.circle(100, 56, 50); circle.getPath(); ---> (Returns a path with string: "M100,56M100,6C138.49001794597504,6.000000000000003,162.54627916220946,47.66666666666667,143.30127018922195,81C134.36963044151787,96.47005383792515,117.86327949540818,106,100,106C61.50998205402496,106,37.453720837790556,64.33333333333334,56.69872981077806,31.000000000000014C65.63036955848214,15.529946162074857,82.13672050459182,6.0000000000000036,100,6C100,6,100,6,100,6" ) circle.transform('s0.5'); circle.getPath(); ---> (Returns the same string above)
Once the element is transformed, its path has changed. It will be really useful to have a method which can give you the 'transformed' path. For the example above, circle.transform('s0.5'); circle.getCurrentPath(); ---> (Can return you the updated path: "M100,56M100,31C119.24500897298752,31,131.27313958110472,51.833333333333336,121.65063509461098,68.5C117.18481522075894,76.23502691896257,108.93163974770408,81,100,81C80.75499102701248,81,68.72686041889528,60.16666666666667,78.34936490538902,43.50000000000001C82.81518477924106,35.764973081037425,91.06836025229592,31,100,31C100,31,100,31,100,31")
Svg maintains the path but changes the transform attribute, the "final" path is resolved by the browser. Seems a difficult task what you are asking.
There's the method Raphael.transformPath(pathString, transformString) which can be used for this purpose :
let circle = paper.circle(100,56,50);
circle.getPath().toString()
"M,100,56,m,0,-50,a,50,50,0,1,1,0,100,a,50,50,0,1,1,0,-100,z"
Raphael.transformPath(circle.getPath(),circle.transform()).toString()
"M100,56M100,-194C100,-194,100,14.333333333333371,100,181C100,258.35026918962575,100,306,100,306C100,306,100,97.66666666666674,100,-68.99999999999994C100,-146.35026918962572,100,-193.99999999999997,100,-194C100,-194,100,-194,100,-194"