# DpOffset

Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Dp.kt+class:androidx.compose.ui.unit.DpOffset) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  value class DpOffset
  ```

*** ** * ** ***

A two-dimensional offset using `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` for units.

To create a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset`, call the top-level function that accepts an x/y pair of coordinates:

```kotlin
val offset = DpOffset(x, y)
```

The primary constructor of `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` is intended to be used with the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#packedValue()` property to allow storing offsets in arrays or collections of primitives without boxing.

## Summary

| ### Nested types |
|---|
| `object https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset.Companion` |

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#Unspecified()` Represents an offset whose `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` are unspecified. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#Zero()` A `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` with 0 DP `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` and 0 DP `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` values. | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#DpOffset(kotlin.Long)(packedValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` | Cmn |

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#copy(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp)(x: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp, y: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` Returns a copy of this `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` instance optionally overriding the x or y parameter | Cmn |
| `operator https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#minus(androidx.compose.ui.unit.DpOffset)(other: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset)` Subtract a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` from another one. | Cmn |
| `operator https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#plus(androidx.compose.ui.unit.DpOffset)(other: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset)` Add a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` to another one. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#packedValue()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` value encoding the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` components of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` The horizontal aspect of the offset in `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` The vertical aspect of the offset in `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | Cmn |

| ### Extension functions |
|---|---|---|
| `inline https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#(androidx.compose.ui.unit.DpOffset).takeOrElse(kotlin.Function0)(block: () -> https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset)` If this `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/package-summary#(androidx.compose.ui.geometry.Offset).isSpecified()` then this is returned, otherwise `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/package-summary#(androidx.compose.ui.unit.DpOffset).takeOrElse(kotlin.Function0)` is executed and its result is returned. | Cmn |

| ### Extension properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#(androidx.compose.ui.unit.DpOffset).isSpecified()` `false` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#Unspecified()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#(androidx.compose.ui.unit.DpOffset).isUnspecified()` `true` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#Unspecified()`. | Cmn |

## Public companion properties

### Unspecified

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
val Unspecified: DpOffset
```

Represents an offset whose `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` are unspecified. This is usually a replacement for `null` when a primitive value is desired. Access to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` on an unspecified offset is not allowed.

### Zero

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Zero: DpOffset
```

A `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` with 0 DP `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` and 0 DP `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` values.

## Public constructors

### DpOffset

Cmn Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
DpOffset(packedValue: Long)
```

| Parameters |
|---|---|
| `packedValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` value encoding the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` components of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset`. Encoded values can be obtained by using the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#packedValue()` property of existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` instances. |

## Public functions

### copy

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun copy(x: Dp = this.x, y: Dp = this.y): DpOffset
```

Returns a copy of this `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` instance optionally overriding the x or y parameter

### minus

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
operator fun minus(other: DpOffset): DpOffset
```

Subtract a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` from another one.

### plus

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
operator fun plus(other: DpOffset): DpOffset
```

Add a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` to another one.

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### packedValue

Cmn Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.8.0)

```
val packedValue: Long
```

`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` value encoding the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#x()` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#y()` components of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset`. Encoded values can be obtained by using the `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#packedValue()` property of existing `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` instances.

### x

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val x: Dp
```

The horizontal aspect of the offset in `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`

### y

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0)

```
val y: Dp
```

The vertical aspect of the offset in `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`

## Extension functions

### DpOffset.takeOrElse

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Dp.kt+function:takeOrElse)

```
inline fun DpOffset.takeOrElse(block: () -> DpOffset): DpOffset
```

If this `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset` `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/package-summary#(androidx.compose.ui.geometry.Offset).isSpecified()` then this is returned, otherwise `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/package-summary#(androidx.compose.ui.unit.DpOffset).takeOrElse(kotlin.Function0)` is executed and its result is returned.

## Extension properties

### DpOffset.isSpecified

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Dp.kt+symbol:isSpecified)

```
val DpOffset.isSpecified: Boolean
```

`false` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#Unspecified()`.

### DpOffset.isUnspecified

Cmn Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/Dp.kt+symbol:isUnspecified)

```
val DpOffset.isUnspecified: Boolean
```

`true` when this is `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpOffset#Unspecified()`.