I want to scale my group (image and something).
group.setScale(zoom, zoom);
But when i scale my group, I think it's not scale from center of my group. i think it like this
I want it scale from center like
I try more but it's not success. How can i do that, thanks.
Problem #1: I need to scale a group from its center. Problem #2: Kinetic JS group.getWidth() and group.getHeight() don't work unless you explicitly set the width at creation. Problem #3: I don't know the width and height, I'm dynamically changing the shapes.
This means in order to try your code out, I'll have to write my own getWidth and getHeight functions. Then I can use the method you propose.
Solution below.
(There may be a better way, but this is my level of programming right now . . . if anyone can add recursion to this to look through groups that contain groups that contain groups etc, that would be great.)
Have you tried to use offset property? i.e. offset: [width/2, height/2]
[Edited to better fit questioner's needs]
Here’s how to scale a Kinetic group from the centerpoint
First we store the centerX and centerY of the original group so we can keep the group centered there:
Then we write a custom scaling method that both scales the group and re-centers it:
Here’s code and a Fiddle: http://jsfiddle.net/m1erickson/dVGGz/
the easiest way would be to reposition / center the offset. all scaling and moving will be based on your new offset position.
http://kineticjs.com/docs/Kinetic.Group.html