uxebu / bonsai

BonsaiJS is a graphics library and renderer
http://bonsaijs.org
Other
1.96k stars 189 forks source link

Order of attributes #210

Closed lmeurs closed 11 years ago

lmeurs commented 11 years ago

Setting origin and rotation cannot be done in one call.

  shape.attr({
    origin: {x: 150, y: 150},
    rotation: .5 // Shape is rotated according previously set origin.
  });

I guess that expected behavior is that attr() respects the order of attributes.

Instead one has to use a separate call, ie.:

  shape.attr({
    origin: {x: 150, y: 150}
  }).attr({
     rotation: .5
  });

And I assumed changing the origin would also affect the positioning of a shape, but it does not. Is this just me or should I submit an issue for this at https://github.com/uxebu/bonsai-docs?

basecode commented 11 years ago

Thanks for reporting this!

I guess that expected behavior is that attr() respects the order of attributes.

Even so I'm not sure whether attr should be applied in order, some attrs definitely need to be applied before others. For example "origin" is supposed to be applied before any other transformation.

"[origin] is applied by first translating the element by the negated value of the property, then applying the element's transform, then translating by the property value."

And I assumed changing the origin would also affect the positioning of a shape, but it does not. Is this just me or should I submit an issue for this at https://github.com/uxebu/bonsai-docs?

I know that's confusing but no, the position is not affected by the origin. The property establishes the starting point of the transformation, which means whatever "origin" you're going to apply, the action "move 30 points to the right" will always remain the same.

lmeurs commented 11 years ago

Great, thank you for your clarification!