---
title: "Size"
description: "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."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
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

<div class='sourceset sourceset-common'>Common</div>


```kotlin
inline val width: Float
```


<div class='sourceset sourceset-common'>Common</div>


```kotlin
inline val height: Float
```


<div class='sourceset sourceset-common'>Common</div>


```kotlin
val minDimension: Float
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val maxDimension: Float
```


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



## Functions

```kotlin
inline operator fun component1(): Float
```

```kotlin
inline operator fun component2(): Float
```

```kotlin
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


```kotlin
fun isEmpty(): Boolean
```


Whether this size encloses a non-zero area.

Negative areas are considered empty.


```kotlin
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`).


```kotlin
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

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Zero = Size(0x0L)
```


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



<div class='sourceset sourceset-common'>Common</div>


```kotlin
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.





