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 byInProgressStrokesView.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.
도형
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인스턴스를 생성하는 팩토리 함수를 제공합니다.
작성
작성 모듈을 사용하면 사용자 포인터 입력을 캡처하고 이를 지연 시간이 짧은 스트로크로 화면에 실시간으로 렌더링할 수 있습니다. 모션 이벤트를 처리하고 획이 그려질 때 획을 표시하는 InProgressStrokesView를 제공합니다.
스트로크가 완료되면 뷰는 등록된 콜백(InProgressStrokesFinishedListener)을 통해 클라이언트 애플리케이션에 알립니다. 콜백을 통해 애플리케이션은 렌더링 또는 저장을 위해 완료된 스트로크를 가져올 수 있습니다.
렌더링
렌더링 모듈은 Android Canvas에 잉크 스트로크를 그리는 데 도움이 됩니다.
Compose에는 CanvasStrokeRenderer를 제공하고 뷰 기반 레이아웃에는 ViewStrokeRenderer를 제공합니다. 이러한 렌더러는 고성능 렌더링을 위해 설계되었으며 앤티앨리어싱을 비롯한 고품질 시각적 요소를 제공하는 데 도움이 됩니다.
스트로크를 렌더링하려면 create() 메서드를 호출하여 CanvasStrokeRenderer 인스턴스를 가져옵니다. 그런 다음 draw() 메서드를 호출하여 완료된 (Stroke) 또는 진행 중인(InProgressStroke) 스트로크를 Canvas에 렌더링합니다.
획을 그릴 때 캔버스를 변환할 수 있습니다. 예를 들어 이동, 확대/축소, 회전 등이 있습니다. 획을 올바르게 렌더링하려면 canvas 변환을 CanvasStrokeRenderer.draw에도 전달해야 합니다.
canvas 변환을 별도로 추적하지 않으려면 대신 ViewStrokeRenderer를 사용하세요.
저장용량
저장소 모듈은 주로 StrokeInputBatch에 중점을 두어 획 데이터를 효율적으로 직렬화하고 역직렬화하는 유틸리티를 제공합니다.
이 모듈은 프로토콜 버퍼와 최적화된 델타 압축 기술을 사용하여 단순한 방법에 비해 상당한 스토리지 절감 효과를 제공합니다.
스토리지 모듈을 사용하면 획을 저장, 로드, 공유하는 작업이 간소화됩니다.