Módulos

La API de Ink está modularizada, por lo que puedes usar solo lo que necesitas.

Brazadas

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 InProgressStrokesView.
  • 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.

Geometría

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.

Pincel

El módulo brush define el estilo de los trazos. Consta de dos partes principales:

  • Brush: Especifica el estilo de un trazo, incluido el color base, el tamaño base y BrushFamily. BrushFamily es análogo a una familia de fuentes, ya que define el estilo de un trazo. Por ejemplo, un BrushFamily puede representar un estilo específico de marcador o resaltador, lo que permite que los trazos con diferentes tamaños y colores compartan ese estilo.
  • StockBrushes: Proporciona funciones de fábrica para crear instancias de BrushFamily listas para usar.

Autoría

The Authoring module lets you capture user pointer input and render it as low-latency strokes on the screen in real time. It provides an InProgressStrokesView, which processes motion events and displays the strokes as they are drawn.

Once a stroke is completed, the view notifies the client application by means of a registered callback (InProgressStrokesFinishedListener). The callback lets the application retrieve the finished stroke for rendering or storage.

Renderización

El módulo de renderización te ayuda a dibujar trazos de tinta en un Canvas de Android. Proporciona CanvasStrokeRenderer para Compose y ViewStrokeRenderer para diseños basados en vistas. Estos renderizadores están diseñados para un renderizado de alto rendimiento y ayudan a ofrecer imágenes de alta calidad, incluido el suavizado.

Para renderizar trazos, llama al método create() para obtener una instancia de CanvasStrokeRenderer. Luego, llama al método draw() para renderizar trazos terminados (Stroke) o en curso (InProgressStroke) en un objeto Canvas.

Puedes transformar el lienzo cuando dibujas un trazo. Algunos ejemplos incluyen el desplazamiento horizontal, el zoom y la rotación. Para renderizar el trazo correctamente, también debes pasar la transformación canvas a CanvasStrokeRenderer.draw.

Para evitar hacer un seguimiento de la transformación canvas por separado, usa ViewStrokeRenderer.

Almacenamiento

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.