Class

LightPosition

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

Source set: Common
public abstract class LightPosition internal constructor()

Where a Light 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
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
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
override fun equals(other: Any?): Boolean

hashCode

Source set: Common
override fun hashCode(): Int

toString

Source set: Common
override fun toString(): String

Global

Source set: Common
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
override fun equals(other: Any?): Boolean

hashCode

Source set: Common
override fun hashCode(): Int

toString

Source set: Common
override fun toString(): String

Anchored

Source set: Common
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. 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
override fun equals(other: Any?): Boolean

hashCode

Source set: Common
override fun hashCode(): Int

toString

Source set: Common
override fun toString(): String
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: