🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

Size

Holds a 2D floating-point size.

Source set: Common
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

Source set: Common
public inline val width: Float

height

Source set: Common
public inline val height: Float

minDimension

Source set: Common
public val minDimension: Float

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

maxDimension

Source set: Common
public val maxDimension: Float

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

Functions

component1

Source set: Common
@Stable public inline operator fun component1(): Float

component2

Source set: Common
@Stable public inline operator fun component2(): Float

copy

Source set: Common
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

Source set: Common
public fun isEmpty(): Boolean

Whether this size encloses a non-zero area.

Negative areas are considered empty.

times

Source set: Common
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

Source set: Common
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

Source set: Common
public companion object

Properties

Zero

Source set: Common
public val Zero: Size

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

Unspecified

Source set: Common
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.