Plush

Layout2D#

PlushEngine · Type index

Namespace: PlushEngine

A Layout 2D component: the object is a rectangle of Width × Height local units placed by rules instead of a hand-set position. AnchorX/AnchorY (0…1) pick a point of the container (the parent's Layout 2D rectangle, else the layer camera's frame); PivotX/PivotY pick the point of this rectangle placed there; OffsetX/OffsetY move it in units. A container with Direction "row" or "column" lays its Layout 2D children out in order with Gap between them inside Padding, aligned across the axis by Align ("start", "center", "end"); their anchors are then ignored. Positions are written to the objects' local 2D transform each frame the frame or a rule changes; rotation and scale stay the author's.

public sealed record Layout2D(float Width = 1, float Height = 1, float AnchorX = .5f, float AnchorY = .5f, float PivotX = .5f, float PivotY = .5f, float OffsetX = 0, float OffsetY = 0, string Direction = "none", float Gap = 0, float Padding = 0, string Align = "center")

Record properties#

PropertyTypeAccessConstructor default
Widthfloatget; init;1
Heightfloatget; init;1
AnchorXfloatget; init;.5f
AnchorYfloatget; init;.5f
PivotXfloatget; init;.5f
PivotYfloatget; init;.5f
OffsetXfloatget; init;0
OffsetYfloatget; init;0
Directionstringget; init;"none"
Gapfloatget; init;0
Paddingfloatget; init;0
Alignstringget; init;"center"

Source#