Moduli
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-07-27 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-27 UTC."],[],[],null,["# Modules\n\nThe [Ink API](/jetpack/androidx/releases/ink#1.0.0-alpha01) is modularized, so you can use only what you need.\n\nStrokes\n-------\n\nThe [Strokes](/reference/kotlin/androidx/ink/strokes/package-summary) module serves as the foundation of the Ink library, offering the\nprimary API interface and containing the core data types for interacting with\nthe library. Key data types within this module include:\n\n- [**`StrokeInputBatch`**](/reference/kotlin/androidx/ink/strokes/StrokeInputBatch): Represents a series of pointer inputs, encompassing position, timestamp, and optionally pressure, tilt, and orientation. This data can be utilized with the [`Stroke`](/reference/kotlin/androidx/ink/strokes/Stroke) or [`InProgressStroke`](/reference/kotlin/androidx/ink/strokes/InProgressStroke) classes, and is the type that would provide the inputs for a handwriting recognition library.\n- [**`Stroke`**](/reference/kotlin/androidx/ink/strokes/Stroke): An immutable representation of a finalized stroke with fixed geometry. Stroke comprises an [`ImmutableStrokeInputBatch`](/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch) (input points), a [`Brush`](/reference/kotlin/androidx/ink/brush/Brush) (styling), and a [`PartitionedMesh`](/reference/kotlin/androidx/ink/geometry/PartitionedMesh) (geometric shape). Strokes can be stored, manipulated, and rendered within your application.\n- [**`InProgressStroke`**](/reference/kotlin/androidx/ink/strokes/InProgressStroke): A mutable counterpart to [`Stroke`](/reference/kotlin/androidx/ink/strokes/Stroke) designed for incremental input handling and real-time rendering during the drawing process. While often used indirectly through [`InProgressStrokesView`](/reference/kotlin/androidx/ink/authoring/InProgressStrokesView), [`InProgressStroke`](/reference/kotlin/androidx/ink/strokes/InProgressStroke) can be leveraged directly for advanced customization.\n\nGeometry\n--------\n\nThe [Geometry](/reference/kotlin/androidx/ink/geometry/package-summary) module\nprovides a suite of geometry primitives for both basic and complex\nshapes along with operations for intersection detection and transformations.\nThese primitives seamlessly integrate with Ink strokes, empowering you to build\nfeatures like whole-stroke erasers and marquee selection tools.\n\nWhile classes like [`Box`](/reference/kotlin/androidx/ink/geometry/Box) and\n[`Vec`](/reference/kotlin/androidx/ink/geometry/Vec) primarily facilitate\ngeometric operations,\n[`PartitionedMesh`](/reference/kotlin/androidx/ink/geometry/PartitionedMesh) may\nalso include rendering-specific data.\n\nBrush\n-----\n\nThe [Brush](/reference/kotlin/androidx/ink/brush/package-summary) module\nacts as a declarative configuration for stroke creation and rendering,\nfunctioning similarly to a text font. A\n[`Brush`](/reference/kotlin/androidx/ink/brush/Brush) object ha the\nfollowing properties:\n\n- **Color**: Can be a solid color or the foundation for layered effects and textures.\n- **Size**: Can be fixed or serve as a base for dynamic size adjustments.\n- **Family**: Analogous to a text typeface, family defines the stroke's overall style.\n- **Epsilon**: Controls the level of detail in the stroke's vector geometry, representing the smallest unit of visual distinction.\n\nThe [`epsilon`](/reference/kotlin/androidx/ink/brush/Brush#epsilon()) property plays a\ncrucial role in defining the precision of your coordinate system. More guidance\nis provided in the [Brush APIs](?tab=t.0#heading=h.j5tn81xa7fph) section on how\nto choose an appropriate epsilon value.\n\nThe [`BrushFamily`](/reference/kotlin/androidx/ink/brush/BrushFamily) serves as\na powerful configuration for creating expressive strokes without delving into\ncomplex geometry or rendering code. The library provides a set of predefined\n[`StockBrushes`](/reference/kotlin/androidx/ink/brush/StockBrushes), including a\npressure-sensitive pen, highlighter, and marker.\n\nAuthoring\n---------\n\nThe [`Authoring`](/reference/kotlin/androidx/ink/authoring/package-summary)\nmodule enables developers to capture user touch input and render it as\nlow-latency strokes on the screen in real-time. This is achieved through the\n[`InProgressStrokesView`](/reference/kotlin/androidx/ink/authoring/InProgressStrokesView) class,\nwhich processes motion events and visualizes the strokes as they're drawn.\n\nOnce a stroke is completed, the module notifies the client application using the\n[`onStrokesFinished()`](/reference/kotlin/androidx/ink/authoring/InProgressStrokesFinishedListener#onStrokesFinished(kotlin.collections.Map))\ncallback of\n[`InProgressStrokesFinishedListener`](/reference/kotlin/androidx/ink/authoring/InProgressStrokesFinishedListener).\nThe callback allows the application to retrieve the\nfinished stroke data for rendering or storage.\n\nRendering\n---------\n\nThe Rendering module simplifies the process of drawing ink strokes onto an\nAndroid [`Canvas`](/reference/kotlin/android/graphics/Canvas). The module\nprovides a [`CanvasStrokeRenderer`](/reference/androidx/ink/rendering/android/canvas/CanvasStrokeRenderer)\nfor Compose and\n[`ViewStrokeRenderer`](/reference/androidx/ink/rendering/android/view/ViewStrokeRenderer)\nfor view-based layouts, both of which optimize rendering performance and ensure\nhigh-quality visuals, including anti-aliasing.\n\nTo render strokes to a canvas, obtain a\n[`CanvasStrokeRenderer`](/reference/kotlin/androidx/ink/rendering/android/canvas/CanvasStrokeRenderer)\ninstance using the\n[`create()`](/reference/kotlin/androidx/ink/rendering/android/canvas/CanvasStrokeRenderer#create())\nmethod. Then, use the\n[`draw()`](/reference/kotlin/androidx/ink/rendering/android/canvas/CanvasStrokeRenderer#draw(android.graphics.Canvas,androidx.ink.strokes.InProgressStroke,androidx.ink.geometry.AffineTransform))\nmethod to render either finished or in-progress strokes.\nstrokes onto a canvas.\n\nThe canvas can be transformed (panned, zoomed, or rotated) as part of drawing the\nstroke, but to make sure the stroke looks its best drawn on screen, the\ntransform applied to the canvas must also be passed to\n`CanvasStrokeRenderer#draw()`.\nTo avoid needing to keep track of this separately, use\n[`ViewStrokeRenderer`](/reference/kotlin/androidx/ink/rendering/android/view/ViewStrokeRenderer)\ninstead."]]