Class

Size

Holds a 2D floating-point size.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Source set: Common

Added in 1.11.0-rc01

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

width

Source set: Common

Added in 1.11.0-rc01

inline val width: Float

height

Source set: Common

Added in 1.11.0-rc01

inline val height: Float

minDimension

Source set: Common

Added in 1.11.0-rc01

val minDimension: Float

The lesser of the magnitudes of the width and the height.

maxDimension

Source set: Common

Added in 1.11.0-rc01

val maxDimension: Float

The greater of the magnitudes of the width and the height.

Functions

component1

Added in 1.11.0-rc01

inline operator fun component1(): Float

component2

Added in 1.11.0-rc01

inline operator fun component2(): Float

copy

Added in 1.11.0-rc01

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

isEmpty

Added in 1.11.0-rc01

fun isEmpty(): Boolean

Whether this size encloses a non-zero area.

Negative areas are considered empty.

times

Added in 1.11.0-rc01

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

Added in 1.11.0-rc01

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

Source set: Common

Added in 1.11.0-rc01

val Zero = Size(0x0L)

An empty size, one with a zero width and a zero height.

Source set: Common

Added in 1.11.0-rc01

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.