Ink API modüler hale getirildiğinden yalnızca ihtiyacınız olanı kullanabilirsiniz.
Vuruşlar
笔画模块是 Ink API 的基础。此模块中的关键数据类型包括:
StrokeInputBatch:表示一系列指针输入,包括其位置、时间戳,以及可选的压力、倾斜度和方向。InProgressStroke:表示正在绘制的笔画。InProgressStroke用于以低延迟渲染部分笔画,并在输入完成后构建最终的Stroke,之后该对象可以重复使用。InProgressStroke由InProgressStrokes可组合项使用。Stroke:已完成的笔画的不可变表示形式,具有固定的几何形状。每个Stroke都有一个ImmutableStrokeInputBatch(输入点)、一个Brush(样式)和一个PartitionedMesh(几何形状)。您可以在应用中存储、处理和渲染笔画。
Geometri
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.
Fırça
brush modülü, konturların stilini tanımlar. İki ana bölümden oluşur:
Brush: Temel renk, temel boyut veBrushFamilydahil olmak üzere bir konturun stilini belirtir.BrushFamily, yazı tipi ailesine benzer ve konturun stilini tanımlar. Örneğin,BrushFamilybelirli bir işaretleyici veya vurgulayıcı stilini temsil edebilir. Bu sayede, farklı boyut ve renklerdeki çizgiler bu stili paylaşabilir.StockBrushes: Kullanıma hazırBrushFamilyörnekleri oluşturmak için fabrika işlevleri sağlar.
Yazma
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.
Oluşturma
Oluşturma modülü, Android'de mürekkep darbeleri çizme işlemini kolaylaştırır.
Canvas
Oluşturma için CanvasStrokeRenderer, görüntülemeye dayalı düzenler için ViewStrokeRenderer sağlar. Bu oluşturucular, oluşturma performansını optimize eder ve kenarları yumuşatma da dahil olmak üzere yüksek kaliteli görseller sunmaya yardımcı olur.
Konturları oluşturmak için create() yöntemini çağırarak bir CanvasStrokeRenderer örneği alın ve ardından draw() yöntemini çağırarak tamamlanmış (Stroke) veya devam eden (InProgressStroke) konturları Canvas üzerine oluşturun.
Fırça darbesi çizerken tuvali dönüştürebilirsiniz. Örnek olarak kaydırma, yakınlaştırma ve döndürme verilebilir. Konturun doğru şekilde oluşturulması için canvas dönüşümünü CanvasStrokeRenderer.draw'ye de aktarmanız gerekir.
canvas dönüşümünün ayrı olarak izlenmesini önlemek için bunun yerine ViewStrokeRenderer kullanın.
Depolama
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.