Size
value class Size(val packedValue: Long)
Holds a 2D floating-point size.
You can think of this as an Offset
from the origin.
To create a Size
, call the top-level function that accepts a width/height pair of dimensions:
val size = Size(width, height)
The primary constructor of Size
is intended to be used with the packedValue
property to allow
storing sizes in arrays or collections of primitives without boxing.
Parameters
packedValue | Long value encoding the width and height components of the Size . Encoded values can be obtained by using the packedValue property of existing Size instances. |
Properties
inline val width: Float
inline val height: Float
val minDimension: Float
The lesser of the magnitudes of the width
and the height
.
val maxDimension: Float
The greater of the magnitudes of the width
and the height
.
Functions
inline operator fun component1(): Float
inline operator fun component2(): Float
fun copy(width: Float = unpackFloat1(packedValue), height: Float = unpackFloat2(packedValue)) =
Size(packFloats(width, height))
Returns a copy of this Size instance optionally overriding the width or height parameter
fun isEmpty(): Boolean
Whether this size encloses a non-zero area.
Negative areas are considered empty.
operator fun times(operand: Float): Size
Multiplication operator.
Returns a Size
whose dimensions are the dimensions of the left-hand-side operand (a Size
)
multiplied by the scalar right-hand-side operand (a Float
).
operator fun div(operand: Float): Size
Division operator.
Returns a Size
whose dimensions are the dimensions of the left-hand-side operand (a Size
)
divided by the scalar right-hand-side operand (a Float
).
Companion Object
Properties
val Zero = Size(0x0L)
An empty size, one with a zero width and a zero height.
val Unspecified = Size(UnspecifiedPackedFloats)
A size whose width
and height
are unspecified. This is a sentinel value used to
initialize a non-null parameter. Access to width or height on an unspecified size is not
allowed.