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. |
InkInputEvent¶
Variants: Begin(sample), Move(sample), Finish(sample = null), Cancel. Deliver one gesture at a time.
InkInputEvent.Begin¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
InkInputEvent.Move¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
InkInputEvent.Finish¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample? |
null |
Real pointer observation; a nullable finishing sample may be omitted. |
InkInputEvent.Cancel¶
InkInputSource¶
subscribe returns an AutoCloseable subscription. Deliver original device observations serially on the UI thread.
InkInputSource.subscribe¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
listener |
(InkInputEvent) -> Unit |
Required |
Serial UI-thread event callback; closing the subscription stops callbacks. |
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.
InkAuthoringController.revision¶
Compose snapshot state, initially 0; changes after processed geometry/lifecycle updates. Private setter.
InkAuthoringController.isDrawing¶
Compose snapshot state, initially false; whether a gesture is active. Private setter.
InkAuthoringController.hasPendingInputs¶
Compose snapshot scheduling state, initially false; append can set it before geometry changes. Private setter.
InkAuthoringController.liveStroke¶
Active engine stroke, or null while idle. Read on the controller's authoring thread.
InkAuthoringController.strokeToView¶
Captured stroke-to-surface transform; initially identity. Private setter.
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. |
InkAuthoringController.append¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
InkAuthoringController.isUpdateNeeded¶
InkAuthoringController.advance¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
uptimeMillis |
Long |
Required |
Nonnegative monotonic event/frame milliseconds, using one clock per gesture. |
InkAuthoringController.finish¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample? |
null |
Real pointer observation; a nullable finishing sample may be omitted. |
InkAuthoringController.cancel¶
InkAuthoringController.close¶
InkDrawingSurface¶
rememberInkAuthoringController¶
Composable: call within a Compose composition.
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. |
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. |