모듈

Ink API는 모듈화되어 있으므로 필요한 것만 사용할 수 있습니다.

The strokes module serves as the foundation of the Ink API. Key data types within this module are:

  • StrokeInputBatch: Represents a series of pointer inputs, including their position, timestamp, and optionally pressure, tilt, and orientation.
  • InProgressStroke: Represents a stroke that is actively being drawn. InProgressStroke is used to render partial strokes with low latency and to build the final Stroke once input is complete, after which the object can be reused. InProgressStroke is used by the InProgressStrokes composable.
  • Stroke: An immutable representation of a finalized stroke with fixed geometry. Each Stroke has an ImmutableStrokeInputBatch (input points), a Brush (style), and a PartitionedMesh (geometric shape). You can store, manipulate, and render strokes within your application.

도형

The Geometry module supports geometric operations on primitive shapes (using dedicated classes like Box and Vec), as well as arbitrary shapes (using PartitionedMesh), including intersection detection and transformation. PartitionedMesh can also hold additional data to support rendering.

브러시

The brush module defines the style of strokes. It consists of two main parts:

  • Brush: Specifies the style of a stroke including base color, base size, and BrushFamily. BrushFamily is analogous to a font family, it defines a stroke's style. For example, a BrushFamily can represent a specific style of marker or highlighter, allowing strokes with different sizes and colors to share that style.
  • StockBrushes: Provides factory functions for creating ready-to-use BrushFamily instances.

작성

The Compose Authoring module lets you capture user touch input and render it as low-latency strokes on the screen in real time. This is achieved through the InProgressStrokes composable, which processes motion events and displays the strokes as they are drawn.

Once a stroke is completed, the composable notifies the client application using an InProgressStrokesFinishedListener callback. This allows the application to retrieve the finished strokes for rendering or storage.

In Compose, InProgressStrokes takes this callback in the onStrokesFinished parameter. Pass the finished strokes to another composable to commit them to the screen using the rendering module.

렌더링

렌더링 모듈은 Android Canvas에 잉크 획을 그리는 작업을 간소화합니다. Compose에는 CanvasStrokeRenderer를 제공하고 뷰 기반 레이아웃에는 ViewStrokeRenderer를 제공합니다. 이러한 렌더러는 렌더링 성능을 최적화하고 앤티앨리어싱을 비롯한 고품질 시각적 요소를 제공하는 데 도움이 됩니다.

획을 렌더링하려면 create() 메서드를 호출하여 CanvasStrokeRenderer 인스턴스를 가져온 다음 draw() 메서드를 호출하여 완료된 (Stroke) 획 또는 진행 중인(InProgressStroke) 획을 Canvas에 렌더링합니다.

획을 그릴 때 캔버스를 변환할 수 있습니다. 예를 들어 이동, 확대/축소, 회전 등이 있습니다. 획을 올바르게 렌더링하려면 canvas 변환을 CanvasStrokeRenderer.draw에도 전달해야 합니다.

canvas 변환을 별도로 추적하지 않으려면 대신 ViewStrokeRenderer를 사용하세요.

저장용량

The storage module provides utilities for efficiently serializing and deserializing stroke data, primarily focusing on StrokeInputBatch.

The module uses protocol buffers and optimized delta compression techniques, resulting in significant storage savings compared to naive methods.

The storage module simplifies saving, loading, and sharing strokes.