StockBrushes
-
android
object 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 |
|---|
|
Version option for the |
|
Version option for the |
|
Version option for the |
|
Version option for the |
|
Version option for the |
Public functions |
||
|---|---|---|
BrushFamily |
dashedLine(version: StockBrushes.DashedLineVersion)Factory function for constructing a brush that appears as rounded rectangles with gaps in between them. |
android
|
BrushFamily |
emojiHighlighter(Factory function for constructing an emoji highlighter brush. |
android
|
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). |
android
|
BrushFamily |
marker(version: StockBrushes.MarkerVersion)Factory function for constructing a simple marker brush. |
android
|
BrushFamily |
pressurePen(version: StockBrushes.PressurePenVersion)Factory function for constructing a pressure- and speed-sensitive brush that is optimized for handwriting with a stylus. |
android
|
Public functions
dashedLine
fun dashedLine(
version: StockBrushes.DashedLineVersion = DashedLineVersion.LATEST
): BrushFamily
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 | |
|---|---|
version: StockBrushes.DashedLineVersion = DashedLineVersion.LATEST |
The version of the dashed line brush to use. By default, uses the latest version. |
emojiHighlighter
fun emojiHighlighter(
clientTextureId: String,
showMiniEmojiTrail: Boolean = false,
selfOverlap: SelfOverlap = SelfOverlap.ANY,
version: StockBrushes.EmojiHighlighterVersion = EmojiHighlighterVersion.LATEST
): BrushFamily
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 | |
|---|---|
clientTextureId: String |
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 |
showMiniEmojiTrail: Boolean = false |
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. |
selfOverlap: SelfOverlap = SelfOverlap.ANY |
Guidance to renderers on how to treat self-overlapping areas of strokes created with this brush. See |
version: StockBrushes.EmojiHighlighterVersion = EmojiHighlighterVersion.LATEST |
The version of the emoji highlighter to use. By default, uses the latest version of the emoji highlighter brush tip and behavior. |
highlighter
fun highlighter(
selfOverlap: SelfOverlap = SelfOverlap.ANY,
version: StockBrushes.HighlighterVersion = HighlighterVersion.LATEST
): BrushFamily
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 | |
|---|---|
selfOverlap: SelfOverlap = SelfOverlap.ANY |
Guidance to renderers on how to treat self-overlapping areas of strokes created with this brush. See |
version: StockBrushes.HighlighterVersion = HighlighterVersion.LATEST |
The version of the highlighter brush to use. By default, uses the latest version. |
marker
fun marker(version: StockBrushes.MarkerVersion = MarkerVersion.LATEST): BrushFamily
Factory function for constructing a simple marker brush.
| Parameters | |
|---|---|
version: StockBrushes.MarkerVersion = MarkerVersion.LATEST |
The version of the marker brush to use. By default, uses the latest version. |
pressurePen
fun pressurePen(
version: StockBrushes.PressurePenVersion = PressurePenVersion.LATEST
): BrushFamily
Factory function for constructing a pressure- and speed-sensitive brush that is optimized for handwriting with a stylus.
| Parameters | |
|---|---|
version: StockBrushes.PressurePenVersion = PressurePenVersion.LATEST |
The version of the pressure pen brush to use. By default, uses the latest version. |