Item position on group translation

155 views
Skip to first unread message

Arnaud Frézet

unread,
May 12, 2013, 11:58:01 AM5/12/13
to pap...@googlegroups.com
Hello,

so first, thanks to work on paper.js, it is an awesome library ! :)

I'm quite new to paper.js, so this is maybe a noob question...
I'm trying to make a game with paper.js. I have a map, which is a collection of paper.Path.Hexagon. I had thoses hexagons to a Group to move them together.
Here is a piece of code :

...
  translate: function (direction) {
    console.log('group', this.group.children[0].position);
    this.group.translate(direction);
    console.log('group', this.group.children[0].position);
  },
...
with direction a paper Vector.

console output : 


The items position does not change after translating the group. But the group translates well. 
So my questions are :
  - Is it a normal behaviour ? If yes, what is the purpose of Groups ?
  - How could I access to the new position of items after an transformation (translation....) on them ?

I hope this is understandable (english is not my first language...)


Thank you !

Pere thinkink

unread,
May 13, 2013, 3:51:42 PM5/13/13
to pap...@googlegroups.com
I think this is a bug, when i group some items and after i ungroup:

ungroup= function( group ){ 
group.parent.addChildren(group.removeChildren()); 
group.remove(); 
paper.project.view.draw(); 
return
}

the items lost some properties like, scale, position. 

My idea is that when a group is scaled the children items doesn't store this modification

Jürg Lehni

unread,
May 13, 2013, 4:29:00 PM5/13/13
to pap...@googlegroups.com
This is not a bug, but probably a design flaw in the current nightly builds, that we're about to address. Pere thinkink's problem has the same source:

Transformations applied to groups or layers are currently not applied to their contents, they are stored in the #matrix property. This is similar to how Flash handles MovieClips.

Here is what I plan to address this issue:

- I'd like to add a new class called Clip that extends Group and exhibits this behavior.
- Group and Layer will change back to applying all transformations directly to their children.

This way we'll have the best of both worlds available, without it taking a toll on code readability.

Sounds good?

Jürg
> --
> You received this message because you are subscribed to the Google Groups "Paper.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Pere thinkink

unread,
May 13, 2013, 6:17:04 PM5/13/13
to pap...@googlegroups.com
thanks for the clarification, Jurg. 

With the matrix information i could retrieve the scale and the position of childs when i ungroup this. But for the rotation i think it's not available in the matrix property. 

The idea of the clip subClass is amazing. I understand that when, ungroup the clip property is posible  pass to  childrens ???

El domingo, 12 de mayo de 2013 17:58:01 UTC+2, Arnaud Frézet escribió:

Jürg Lehni

unread,
May 13, 2013, 8:43:01 PM5/13/13
to pap...@googlegroups.com
We're very close to fixing this, so I suggest you just wait another day and the issue will magically disappear :)

Jürg Lehni

unread,
May 13, 2013, 9:58:29 PM5/13/13
to pap...@googlegroups.com
This went faster than I thought, and is already in the nightly build now:

http://paperjs.org/download/

Best,

Jürg

Pere thinkink

unread,
May 14, 2013, 7:33:20 AM5/14/13
to pap...@googlegroups.com
Ok, it's magic. Works fine for me thanks a lot and another question:

I open a issue last week:


can you tell me something about it


El domingo, 12 de mayo de 2013 17:58:01 UTC+2, Arnaud Frézet escribió:

Pere thinkink

unread,
May 14, 2013, 7:37:13 AM5/14/13
to pap...@googlegroups.com
When i apply a transparency seems the item lost the position and scale, It's posible is the same problem and arrange it with the new clip Class???


El domingo, 12 de mayo de 2013 17:58:01 UTC+2, Arnaud Frézet escribió:

Arnaud Frézet

unread,
May 14, 2013, 8:10:27 AM5/14/13
to pap...@googlegroups.com
Ok
i will test this when I'll get time.

Thks


2013/5/14 Pere thinkink <essa...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Paper.js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/paperjs/OlwOxAs0dx8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to paperjs+u...@googlegroups.com.

Jürg Lehni

unread,
May 14, 2013, 11:05:25 AM5/14/13
to pap...@googlegroups.com
I think that's a different issue that needs more analysis. Will hopefully have some time later today.
> You received this message because you are subscribed to the Google Groups "Paper.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.

Arnaud Frézet

unread,
May 17, 2013, 2:30:32 PM5/17/13
to pap...@googlegroups.com
I have just downloaded the nightly build and the position update correctly when i move the group.

Thank you !


Reply all
Reply to author
Forward
0 new messages