Link Search Menu Expand Document

Size

The setfenv(…) (in meters) of a view or element in the world.

Note that size and scale are different things: size is the semantic size of your app (e g “this button is 2 dm wide”) while scale is the scaling up or down of this semantic size (e g a transformation matrix with a 2.0 X-axis scale and a 2dm width is 4dm wide, but its content is still 2dm wide.)

Constructor

 size = Size(width, height, depth)

Arguments

Name Type Description
width number The width of the component.
height number The height of the component.
depth number The depth of the component.

Returns

Nothing


Methods

size:copy ()

Creates and returns a copy of a given Size.

Arguments

None

Returns

Type Description
Size A copy of the original Size object.

size:inset (byWidth, byHeight, byDepth)

Shrinks the Size component by the given parameters.

Arguments

Name Type Description
byWidth number The x component of the size reduction.
byHeight number The y component of the size reduction.
byDepth number The z component of the size reduction.

Returns

Type Description
Size The original Size object, post-resize.

size:set (width, height, depth)

Sets width, height and depth

Arguments

Name Type Description
width number The width of the component.
height number The height of the component.
depth number The depth of the component.

Returns

Nothing


size:getEdge (vertical, horizontal, depthwise)

Returns the position relative to the object’s edge(s).

Very useful for laying out information, such as positioning a Label in the top center of my_container:

 local my_label = ui.Label{
   bounds = ui.Bounds{size=ui.Size(1, 0.15, 0.1)}:move (
     my_container.bounds.size:getEdge("top", "center")
   )
 }

Arguments

Name Type Description
vertical String “top”, “center” (default) or “bottom”.
horizontal String “left”, “center” (default) or “right”.
depthwise String “front”, “center” (default) or “back”.

Returns

Type Description
vector A vector (x, y, z) with coordinates corresponding to the requested position of the given Size object.