public class Size(public 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
width
public inline val width: Float
height
public inline val height: Float
minDimension
public val minDimension: Float
The lesser of the magnitudes of the width and the height.
maxDimension
public val maxDimension: Float
The greater of the magnitudes of the width and the height.
Functions
component1
@Stable public inline operator fun component1(): Float
component2
@Stable public inline operator fun component2(): Float
copy
public fun copy(
width: Float = unpackFloat1(packedValue),
height: Float = unpackFloat2(packedValue),
): Size
Returns a copy of this Size instance optionally overriding the width or height parameter
isEmpty
public fun isEmpty(): Boolean
Whether this size encloses a non-zero area.
Negative areas are considered empty.
times
public 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).
div
public 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).
Members
Companion
public companion object
Properties
Zero
public val Zero: Size
An empty size, one with a zero width and a zero height.
Unspecified
public val Unspecified: Size
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.