excessive / DOMy

A DOM-like GUI framework for the *awesome* LÖVE framework
Other
32 stars 2 forks source link

Anchor Points #17

Open karai17 opened 9 years ago

karai17 commented 9 years ago

It was suggested in the forum thread that anchor points for elements would be wise. An archor point is defined as the point of an element where positioning takes place. For instance, by default anchor points would be Top-Left, or 0,0. If I want to position an element at 0.5,0.0 on screen, then the top-left corner of the element will be in the middle of the screen on the x axis. If the anchor point is Top-Right or 1,0, then the top-right corner will be at the 50% mark.

The most notable use case for this is allowing elements to resize in any desired direction. If you set the anchor to the centre of the object, then when you resize the object it will stay where it is located but grow or shrink outward. If you set the anchor point of an object to the bottom centre, then you can grow or shrink an object to the edge of the screen.

So I guess the question here is, should there be a set of defined anchor points (TL, TC, TR, L, C, R, BL, BC, BR) or should the anchor be definable based on a % value? vec2(0.25,0.78) would set the anchor point to 25% from the left and 78% from the top.

Bobbyjoness commented 9 years ago

I like the idea of anchor points. I wish regular love had them for the shapes.