# LightPosition

> Where a [Light] sits, and the coordinate space that position is measured in.

## API Reference

> Source set: Common

```kotlin
public abstract class LightPosition internal constructor()
```

Where a [Light](https://composables.com/jetpack-compose/androidx.compose.ui/ui/classes/Light/api.md) sits, and the coordinate space that position is measured in.

All three variants resolve to a point in the lit composable's own space; they differ only in what
`offset` is measured from. Use `Local` for a light that belongs to the composable it lights,
`Global` for one placed against the root composable, and `Anchored` for one that should follow
another composable.

## Properties

### offset

> Source set: Common

```kotlin
public abstract val offset: DpOffset
```

Position of the light within the coordinate space this describes, with `x` increasing to the
right and `y` increasing downwards.

## Members

### Local

> Source set: Common

```kotlin
public class Local(override val offset: DpOffset) : LightPosition()
```

A position measured from the top-left corner of the composable being lit.

The light is part of that composable and moves with it, so the shading does not change as the
composable is scrolled or repositioned. This is the cheapest option, as no coordinate
conversion is required.

#### Parameters

| | |
| --- | --- |
| offset | position of the light relative to the lit composable's top-left corner. |

## Functions

### equals

> Source set: Common

```kotlin
override fun equals(other: Any?): Boolean
```

### hashCode

> Source set: Common

```kotlin
override fun hashCode(): Int
```

### toString

> Source set: Common

```kotlin
override fun toString(): String
```

### Global

> Source set: Common

```kotlin
public class Global(override val offset: DpOffset) : LightPosition()
```

A position measured from the top-left corner of the root of the composition that hosts the
lit composable, the same space as positionInRoot. A Popup or Dialog has its own root.

The light is fixed in the root composable, so moving or scrolling the lit composable moves it
through the light and the shading changes accordingly. Use this for a single light shared by
several composables that should agree on where it is.

#### Parameters

| | |
| --- | --- |
| offset | position of the light relative to the root's top-left corner. |

## Functions

### equals

> Source set: Common

```kotlin
override fun equals(other: Any?): Boolean
```

### hashCode

> Source set: Common

```kotlin
override fun hashCode(): Int
```

### toString

> Source set: Common

```kotlin
override fun toString(): String
```

### Anchored

> Source set: Common

```kotlin
public class Anchored(
        public val state: LightAnchorState,
        override val offset: DpOffset = DpOffset.Zero,
    ) : LightPosition()
```

A position measured from the composable that `state` is attached to with [lightAnchor](https://composables.com/jetpack-compose/androidx.compose.ui/ui/modifiers/lightAnchor/api.md). The
anchor must be in the same composition hierarchy as the lit composable. An anchor in a
different Popup, Dialog or ComposeView contributes no light.

The light follows that composable wherever it is laid out, without either composable needing
to know about the other. Until the anchored composable has been placed the position cannot be
resolved and the light contributes nothing.

#### Parameters

| | |
| --- | --- |
| state | the anchor to position against. Two anchored positions are equal only when they share the same state instance. |
| offset | position of the light relative to the anchored composable's top-left corner. |

## Functions

### equals

> Source set: Common

```kotlin
override fun equals(other: Any?): Boolean
```

### hashCode

> Source set: Common

```kotlin
override fun hashCode(): Int
```

### toString

> Source set: Common

```kotlin
override fun toString(): String
```
