Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to scale a path in raphael.js

I don't understand why the following example is not working... It only works if I am resizing it once but if I try to resize it again it get's all messed up...

http://jsfiddle.net/JAVWN/1/

like image 268
fogy Avatar asked May 05 '11 01:05

fogy


2 Answers

You would think that if you called scale() once and then called scale() again, the results would be cumulative, but this doesn't seem to be the case. It seems that if you call scale(), it remembers the original dimensions and scales those rather than the previously recalculated dimensions.

The way I got your example to work was to store the scale (one variable for each dimension) on your object (starting with scaleX = scaleY = 1). Then I multiplied the stored scale by the scale calculated from the final position of the resizer/cursor and stored those in your object. Finally, I used the stored scales in the scale() function call to resize your shapes.

See http://jsfiddle.net/donniec/JAVWN/2/

like image 161
Donnie C Avatar answered Jan 02 '23 08:01

Donnie C


I fixed it... just use node.resetScale();

like image 42
fogy Avatar answered Jan 02 '23 09:01

fogy