StockBrushes
public static class StockBrushes
Provides a fixed set of stock BrushFamily objects that any app can use.
All stock brushes are versioned, so apps can store input points and brush specs instead of the pixel result, but be able to regenerate strokes from stored input points that look generally like the strokes originally drawn by the user. Stock brushes are intended to evolve over time.
Each successive stock brush version will keep to the spirit of the brush, but the details can change between versions. For example, a new version of the highlighter may introduce a variation on how round the tip is, or what sort of curve maps color to pressure.
We generally recommend that applications use the latest brush version available, which is what the factory functions in this class do by default. But for some artistic use-cases, it may be useful to specify a specific stock brush version to minimize visual changes when the Ink dependency is upgraded. For example, the following will always return the initial version of the marker stock brush.
val markerBrush = StockBrushes.marker(StockBrushes.MarkerVersion.V1)
Specific stock brushes may see minor tweaks and bug-fixes when the library is upgraded, but will avoid major changes in behavior.
Summary
Nested types |
|---|
public final class StockBrushes.DashedLineVersionVersion option for the |
public final class StockBrushes.EmojiHighlighterVersionVersion option for the |
public final class StockBrushes.HighlighterVersionVersion option for the |
public final class StockBrushes.MarkerVersionVersion option for the |
public final class StockBrushes.PressurePenVersionVersion option for the |
Public fields |
|
|---|---|
static @NonNull StockBrushes |
Public methods |
|
|---|---|
static final @NonNull BrushFamily |
dashedLine(@NonNull StockBrushes.DashedLineVersion version)Factory function for constructing a brush that appears as rounded rectangles with gaps in between them. |
static final @NonNull BrushFamily |
emojiHighlighter(Factory function for constructing an emoji highlighter brush. |
static final @NonNull BrushFamily |
highlighter(Factory function for constructing a chisel-tip brush that is intended for highlighting text in a document (when used with a translucent brush color). |
static final @NonNull BrushFamily |
marker(@NonNull StockBrushes.MarkerVersion version)Factory function for constructing a simple marker brush. |
static final @NonNull BrushFamily |
Factory function for constructing a pressure- and speed-sensitive brush that is optimized for handwriting with a stylus. |
Public fields
Public methods
dashedLine
public static final @NonNull BrushFamily dashedLine(@NonNull StockBrushes.DashedLineVersion version)
Factory function for constructing a brush that appears as rounded rectangles with gaps in between them. This may be decorative, or can be used to signify a user interaction like free-form (lasso) selection.
| Parameters | |
|---|---|
@NonNull StockBrushes.DashedLineVersion version |
The version of the dashed line brush to use. By default, uses the latest version. |
emojiHighlighter
public static final @NonNull BrushFamily emojiHighlighter(
@NonNull String clientTextureId,
boolean showMiniEmojiTrail,
@NonNull SelfOverlap selfOverlap,
@NonNull StockBrushes.EmojiHighlighterVersion version
)
Factory function for constructing an emoji highlighter brush.
In order to use this brush, the TextureBitmapStore provided to your renderer must map the clientTextureId to a bitmap; otherwise, no texture will be visible. The emoji bitmap should be a square, though the image can have a transparent background for emoji shapes that aren't square.
| Parameters | |
|---|---|
@NonNull String clientTextureId |
The client texture ID of the emoji to appear at the end of the stroke. This ID should map to a square bitmap with a transparent background in the implementation of androidx.ink.brush.TextureBitmapStore passed to |
boolean showMiniEmojiTrail |
Whether to show a trail of miniature emojis disappearing from the stroke as it is drawn. Note that this will only render properly starting with Android U, and before Android U it is recommended to set this to false. |
@NonNull SelfOverlap selfOverlap |
Guidance to renderers on how to treat self-overlapping areas of strokes created with this brush. See |
@NonNull StockBrushes.EmojiHighlighterVersion version |
The version of the emoji highlighter to use. By default, uses the latest version of the emoji highlighter brush tip and behavior. |
highlighter
public static final @NonNull BrushFamily highlighter(
@NonNull SelfOverlap selfOverlap,
@NonNull StockBrushes.HighlighterVersion version
)
Factory function for constructing a chisel-tip brush that is intended for highlighting text in a document (when used with a translucent brush color).
| Parameters | |
|---|---|
@NonNull SelfOverlap selfOverlap |
Guidance to renderers on how to treat self-overlapping areas of strokes created with this brush. See |
@NonNull StockBrushes.HighlighterVersion version |
The version of the highlighter brush to use. By default, uses the latest version. |
marker
public static final @NonNull BrushFamily marker(@NonNull StockBrushes.MarkerVersion version)
Factory function for constructing a simple marker brush.
| Parameters | |
|---|---|
@NonNull StockBrushes.MarkerVersion version |
The version of the marker brush to use. By default, uses the latest version. |
pressurePen
public static final @NonNull BrushFamily pressurePen(@NonNull StockBrushes.PressurePenVersion version)
Factory function for constructing a pressure- and speed-sensitive brush that is optimized for handwriting with a stylus.
| Parameters | |
|---|---|
@NonNull StockBrushes.PressurePenVersion version |
The version of the pressure pen brush to use. By default, uses the latest version. |