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.InProgressStrokeis used to render partial strokes with low latency and to build the finalStrokeonce input is complete, after which the object can be reused.InProgressStrokeis used by theInProgressStrokescomposable.Stroke: An immutable representation of a finalized stroke with fixed geometry. EachStrokehas anImmutableStrokeInputBatch(input points), aBrush(style), and aPartitionedMesh(geometric shape). You can store, manipulate, and render strokes within your application.
도형
Geometry 모듈은 교차 감지 및 변환을 비롯하여 기본 도형 (Box 및 Vec과 같은 전용 클래스 사용)과 임의 도형 (PartitionedMesh 사용)에 관한 기하학적 작업을 지원합니다. PartitionedMesh는 렌더링을 지원하기 위해 추가 데이터를 보유할 수도 있습니다.
브러시
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를 사용하세요.
저장용량
저장소 모듈은 주로 StrokeInputBatch에 중점을 두어 획 데이터를 효율적으로 직렬화하고 역직렬화하는 유틸리티를 제공합니다.
이 모듈은 프로토콜 버퍼와 최적화된 델타 압축 기술을 사용하여 단순한 방법에 비해 상당한 스토리지 절감 효과를 제공합니다.
스토리지 모듈을 사용하면 획을 저장, 로드, 공유하는 작업이 간소화됩니다.