모듈

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.

브러시

brush 모듈은 획의 스타일을 정의합니다. 다음 두 가지 주요 부분으로 구성됩니다.

  • Brush: 기본 색상, 기본 크기, BrushFamily을 비롯한 획의 스타일을 지정합니다. BrushFamily는 글꼴 모음과 유사하며 획의 스타일을 정의합니다. 예를 들어 BrushFamily는 특정 스타일의 마커나 형광펜을 나타낼 수 있으므로 크기와 색상이 다른 획이 해당 스타일을 공유할 수 있습니다.
  • StockBrushes: 바로 사용할 수 있는 BrushFamily 인스턴스를 생성하는 팩토리 함수를 제공합니다.

작성

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.