Skip to content

Input and authoring

Module: byteink-compose. Conventions. Signatures and defaults follow the current source.

InkPointerSample

InkPointerSample

Coordinates must be finite, uptime nonnegative, measured pressure finite within [0, 1].

public data class InkPointerSample( public val x: Float, public val y: Float, public val uptimeMillis: Long, public val toolType: InputToolType = InputToolType.MOUSE, public val pressure: Float? = null, )
Parameter Type Default Meaning
x Float Required Horizontal coordinate; surface pixels for pointer samples, page dp for InkPoint.
y Float Required Vertical coordinate; surface pixels for pointer samples, page dp for InkPoint.
uptimeMillis Long Required Nonnegative monotonic event/frame milliseconds, using one clock per gesture.
toolType InputToolType InputToolType.MOUSE Device tool type; keep it constant within a gesture.
pressure Float? null Measured finite pressure in [0, 1], or null when unavailable; Int brush levels use 0–5.

Source

InkInputEvent

Variants: Begin(sample), Move(sample), Finish(sample = null), Cancel. Deliver one gesture at a time.

public sealed interface InkInputEvent

Source

InkInputEvent.Begin

public data class Begin(public val sample: InkPointerSample) : InkInputEvent
Parameter Type Default Meaning
sample InkPointerSample Required Real pointer observation; a nullable finishing sample may be omitted.

Source

InkInputEvent.Move

public data class Move(public val sample: InkPointerSample) : InkInputEvent
Parameter Type Default Meaning
sample InkPointerSample Required Real pointer observation; a nullable finishing sample may be omitted.

Source

InkInputEvent.Finish

public data class Finish(public val sample: InkPointerSample? = null) : InkInputEvent
Parameter Type Default Meaning
sample InkPointerSample? null Real pointer observation; a nullable finishing sample may be omitted.

Source

InkInputEvent.Cancel

public data object Cancel : InkInputEvent

Source

InkInputSource

subscribe returns an AutoCloseable subscription. Deliver original device observations serially on the UI thread.

public interface InkInputSource

Source

InkInputSource.subscribe

public fun subscribe(listener: (InkInputEvent) -> Unit): AutoCloseable
Parameter Type Default Meaning
listener (InkInputEvent) -> Unit Required Serial UI-thread event callback; closing the subscription stops callbacks.

Source

InkAuthoringController

InkAuthoringController

begin draws the first dot; append buffers; advance processes a frame; finish returns canonical finished geometry or null when idle. close is terminal.

public class InkAuthoringController : AutoCloseable

Source

InkAuthoringController.revision

public var revision: Long

Compose snapshot state, initially 0; changes after processed geometry/lifecycle updates. Private setter.

Source

InkAuthoringController.isDrawing

public var isDrawing: Boolean

Compose snapshot state, initially false; whether a gesture is active. Private setter.

Source

InkAuthoringController.hasPendingInputs

public var hasPendingInputs: Boolean

Compose snapshot scheduling state, initially false; append can set it before geometry changes. Private setter.

Source

InkAuthoringController.liveStroke

public val liveStroke: InProgressStroke?

Active engine stroke, or null while idle. Read on the controller's authoring thread.

Source

InkAuthoringController.strokeToView

public var strokeToView: AffineTransform

Captured stroke-to-surface transform; initially identity. Private setter.

Source

InkAuthoringController.begin

public fun begin( brush: Brush, sample: InkPointerSample, strokeToView: AffineTransform = AffineTransform.IDENTITY, )
Parameter Type Default Meaning
brush Brush Required Native brush captured at gesture start; keep stored metadata consistent with it.
sample InkPointerSample Required Real pointer observation; a nullable finishing sample may be omitted.
strokeToView AffineTransform AffineTransform.IDENTITY Finite invertible stroke/page-to-surface-pixel transform, snapshotted at begin.

Source

InkAuthoringController.append

public fun append(sample: InkPointerSample): Boolean
Parameter Type Default Meaning
sample InkPointerSample Required Real pointer observation; a nullable finishing sample may be omitted.

Source

InkAuthoringController.isUpdateNeeded

public fun isUpdateNeeded(): Boolean

Source

InkAuthoringController.advance

public fun advance(uptimeMillis: Long): Boolean
Parameter Type Default Meaning
uptimeMillis Long Required Nonnegative monotonic event/frame milliseconds, using one clock per gesture.

Source

InkAuthoringController.finish

public fun finish(sample: InkPointerSample? = null): Stroke?
Parameter Type Default Meaning
sample InkPointerSample? null Real pointer observation; a nullable finishing sample may be omitted.

Source

InkAuthoringController.cancel

public fun cancel()

Source

InkAuthoringController.close

override public fun close()

Source

InkDrawingSurface

rememberInkAuthoringController

Composable: call within a Compose composition.

public fun rememberInkAuthoringController(): InkAuthoringController

Source

InkDrawingSurface

Captures brush, transform and callback at pointer down. Disabling/removal cancels; the owner must close the controller and clear the renderer.

Composable: call within a Compose composition.

public fun InkDrawingSurface( controller: InkAuthoringController, brush: Brush, modifier: Modifier = Modifier, strokeToView: AffineTransform = AffineTransform.IDENTITY, renderer: InkPathRenderer = remember { InkPathRenderer() }, enabled: Boolean = true, inputSource: InkInputSource? = null, onStrokeFinished: (Stroke) -> Unit, drawContent: DrawScope.() -> Unit = {}, )
Parameter Type Default Meaning
controller InkAuthoringController Required UI-thread authoring controller; attach to one surface at a time.
brush Brush Required Native brush captured at gesture start; keep stored metadata consistent with it.
modifier Modifier Modifier Compose layout, sizing and drawing modifiers.
strokeToView AffineTransform AffineTransform.IDENTITY Finite invertible stroke/page-to-surface-pixel transform, snapshotted at begin.
renderer InkPathRenderer remember { InkPathRenderer() } Reusable drawing-thread renderer; clear path caches or close owned mesh renderers on disposal.
enabled Boolean true Whether to accept input; false cancels the active gesture.
inputSource InkInputSource? null Optional native adapter; null uses Compose primary-pointer gestures.
onStrokeFinished (Stroke) -> Unit Required Completion callback captured at pointer down; retain/store the returned stroke.
drawContent DrawScope.() -> Unit {} DrawScope block drawn before live ink, usually for finished ink and paper.

Source

InkDrawingSurface

Captures brush, transform and callback at pointer down. Disabling/removal cancels; the owner must close the controller and clear the renderer.

Composable: call within a Compose composition.

public fun InkDrawingSurface( controller: InkAuthoringController, brush: Brush, modifier: Modifier = Modifier, strokeToView: AffineTransform = AffineTransform.IDENTITY, renderer: InkRenderer, enabled: Boolean = true, inputSource: InkInputSource? = null, onStrokeFinished: (Stroke) -> Unit, drawContent: DrawScope.() -> Unit = {}, )
Parameter Type Default Meaning
controller InkAuthoringController Required UI-thread authoring controller; attach to one surface at a time.
brush Brush Required Native brush captured at gesture start; keep stored metadata consistent with it.
modifier Modifier Modifier Compose layout, sizing and drawing modifiers.
strokeToView AffineTransform AffineTransform.IDENTITY Finite invertible stroke/page-to-surface-pixel transform, snapshotted at begin.
renderer InkRenderer Required Reusable drawing-thread renderer; clear path caches or close owned mesh renderers on disposal.
enabled Boolean true Whether to accept input; false cancels the active gesture.
inputSource InkInputSource? null Optional native adapter; null uses Compose primary-pointer gestures.
onStrokeFinished (Stroke) -> Unit Required Completion callback captured at pointer down; retain/store the returned stroke.
drawContent DrawScope.() -> Unit {} DrawScope block drawn before live ink, usually for finished ink and paper.

Source