Modüller

Ink API modüler hale getirildiğinden yalnızca ihtiyacınız olanı kullanabilirsiniz.

Vuruşlar

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.

Geometri

Geometry modülü, kesişim algılama ve dönüştürme dahil olmak üzere, ilkel şekiller (Box ve Vec gibi özel sınıflar kullanılarak) ve rastgele şekiller (PartitionedMesh kullanılarak) üzerinde geometrik işlemleri destekler. PartitionedMesh, oluşturmayı desteklemek için ek veriler de içerebilir.

Fırça

brush modülü, konturların stilini tanımlar. İki ana bölümden oluşur:

  • Brush: Temel renk, temel boyut ve BrushFamily dahil olmak üzere bir konturun stilini belirtir. BrushFamily, yazı tipi ailesine benzer ve konturun stilini tanımlar. Örneğin, BrushFamily belirli bir işaretleyici veya vurgulayıcı stilini temsil edebilir. Bu sayede, farklı boyut ve renklerdeki çizgiler bu stili paylaşabilir.
  • StockBrushes: Kullanıma hazır BrushFamily ö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.