User Tools

Site Tools


en:tutorials:objects:literals_for_objects

Position literals to align with Parent Objects

Using literals for object positioning adds flexibility for placing an object relative to its parent, without having to do manual calculations.

This is especially useful in the context of UI.

Furthermore, when a Parent is defined for an object, you can use the same literals for Position as with Pivot to align object inside parent's borders.

The global form is:

  Position = [pivot's override ->] Position's in parent space

Here's a basic setup with one rectangular parent (green) and one rectangular child (red):

[Parent]
Color     = lime green
Size      = (400, 300)
Pivot     = center
ChildList = Child
 
[Child]
Color     = orange red
Size      = (200, 150)
Pivot     = center
Position  = (0, 0, -0.1)

And its result (nothing unusual so far):

The Pivot of each rectangle will be highlighted with a small lighter colored square Let's try a few things and see the results

[Parent]
Pivot     = center
 
[Child]
Pivot     = center
Position  = top right

[Parent]
Pivot     = center
 
[Child]
Pivot     = top left
Position  = top left

[Parent]
Pivot     = left
 
[Child]
Pivot     = bottom right
Position  = top left (10, 10, -0.1)

[Parent]
Pivot     = left
 
[Child]
Pivot     = bottom left
Position  = bottom right -> bottom left

[Parent]
Pivot     = left
 
[Child]
Pivot     = (20, 20)
Position  = (100, 100) -> bottom left -0.1

[Parent]
Pivot           = left
 
[Child]
UseParentSpace  = position
Pivot           = center
Position        = top right -> (0, 0.1)

[Parent]
Pivot     = left
 
[Child]
Pivot     = (20, 20)
Scale     = 0.5
Rotation  = 30
Position  = bottom right -> bottom left -0.1

One last for the road….

[Parent]
Pivot           = left
Rotation        = -30
Scale           = 0.5
 
[Child]
UseParentSpace  = position
Pivot           = top right
Scale           = 2
Rotation        = 30
Position        = bottom right -> bottom left (0.25, 0, 0.1)

en/tutorials/objects/literals_for_objects.txt · Last modified: 2021/08/18 22:27 (3 years ago) by iarwain