---
title: "IntOffset"
description: "A two-dimensional position using [Int] pixels for units.

To create an [IntOffset], call the top-level function that accepts an x/y pair of coordinates:
```
val offset = IntOffset(x, y)
```

The primary constructor of [IntOffset] is intended to be used with the [packedValue] property to
allow storing offsets 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 IntOffset(val packedValue: Long)
```


A two-dimensional position using `Int` pixels for units.

To create an `IntOffset`, call the top-level function that accepts an x/y pair of coordinates:
```
val offset = IntOffset(x, y)
```

The primary constructor of `IntOffset` is intended to be used with the `packedValue` property to
allow storing offsets in arrays or collections of primitives without boxing.

#### Parameters

| | |
| --- | --- |
| packedValue | `Long` value encoding the `x` and `y` components of the `IntOffset`. Encoded values can be obtained by using the `packedValue` property of existing `IntOffset` instances. |



## Properties

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


```kotlin
val x: Int
```


The horizontal aspect of the position in `Int` pixels.



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


```kotlin
val y: Int
```


The vertical aspect of the position in `Int` pixels.



## Functions

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

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

```kotlin
fun copy(x: Int = unpackInt1(packedValue), y: Int = unpackInt2(packedValue)) =
        IntOffset(packInts(x, y))
```


Returns a copy of this IntOffset instance optionally overriding the x or y parameter


```kotlin
operator fun minus(other: IntOffset) =
        IntOffset(
            packInts(
                unpackInt1(packedValue) - unpackInt1(other.packedValue),
                unpackInt2(packedValue) - unpackInt2(other.packedValue),
            )
        )
```


Subtract a `IntOffset` from another one.


```kotlin
operator fun plus(other: IntOffset) =
        IntOffset(
            packInts(
                unpackInt1(packedValue) + unpackInt1(other.packedValue),
                unpackInt2(packedValue) + unpackInt2(other.packedValue),
            )
        )
```


Add a `IntOffset` to another one.


```kotlin
operator fun unaryMinus() =
        IntOffset(packInts(-unpackInt1(packedValue), -unpackInt2(packedValue)))
```


Returns a new `IntOffset` representing the negation of this point.


```kotlin
operator fun times(operand: Float): IntOffset
```


Multiplication operator.

Returns an IntOffset whose coordinates are the coordinates of the left-hand-side operand (an
IntOffset) multiplied by the scalar right-hand-side operand (a Float). The result is rounded
to the nearest integer.


```kotlin
operator fun div(operand: Float): IntOffset
```


Division operator.

Returns an IntOffset whose coordinates are the coordinates of the left-hand-side operand (an
IntOffset) divided by the scalar right-hand-side operand (a Float). The result is rounded to
the nearest integer.


```kotlin
operator fun rem(operand: Int) =
        IntOffset(packInts(unpackInt1(packedValue) % operand, unpackInt2(packedValue) % operand))
```


Modulo (remainder) operator.

Returns an IntOffset whose coordinates are the remainder of dividing the coordinates of the
left-hand-side operand (an IntOffset) by the scalar right-hand-side operand (an Int).


## Companion Object

#### Properties

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


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


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


```kotlin
val Max = IntOffset(0x7FFF_FFFF_7FFF_FFFF)
```




