Generated banner for Ink Custom Brush Builder
Generated logo for Ink Custom Brush Builder

Ink Custom Brush Builder

Android (Google)OfficialCreated by Google LLCDistributed by Android (Google)

  • Skill
  • Tool integration
  • Software development
  • Apache-2.0
  • No issues found

From the author

Creates custom BrushFamily definitions for an Android app using Jetpack Ink (androidx.ink 1.1.0-alpha03 and higher). Use this skill when configuring custom BrushTip shapes, adding pressure, tilt, speed, or noise sensitivity using BrushBehavior node graphs, creating multi-coat layered brushes, applying tiling or particle stamping textures, configuring SlidingWindowModel input smoothing, or serializing brushes. Delivers complete Kotlin BrushFamily, BrushCoat, BrushTip, BrushPaint, and BrushBehavior implementations. Don't use for View-based (XML) inking, Compose drawing surface setup, or stock brush selection. For Compose drawing surface setup, InProgressStrokes wet and dry rendering, eraser, or persistence, suggest the ink-app-builder skill.
— the description by Google LLC

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The ink-custom-brush-builder skill provides a structured approach to creating programmatic custom brushes for Android applications utilizing the Jetpack Ink library (version 1.1.0-alpha03 and higher). It enables developers to define complex brush behaviors, multi-coat layers, and custom textures using Kotlin constructors rather than manual protocol buffer builders. The skill covers the entire brush hierarchy, including BrushFamily, BrushCoat, BrushTip, BrushPaint, and BrushBehavior node graphs, ensuring developers can implement responsive, high-fidelity drawing tools with features like pressure, tilt, and speed sensitivity.

What it does

  • Generates complete Kotlin implementations for BrushFamily, BrushCoat, BrushTip, BrushPaint, and BrushBehavior.
  • Configures dynamic stylus and touch responses using BrushBehavior node graphs.
  • Applies tiling or particle stamping textures to brushes.
  • Sets up input smoothing via SlidingWindowModel.
  • Provides guidance on encoding and decoding custom BrushFamily definitions.
  • Ensures correct dependency versions for Jetpack Ink libraries.

When to use it

  • When you need to create custom brush styles beyond the provided stock brushes.
  • When implementing brushes that respond dynamically to stylus pressure, tilt, or speed.
  • When building multi-coat layered brushes with specific texture or color functions.
  • When you need to serialize and deserialize custom brush definitions.
  • When configuring specific input smoothing for drawing strokes.

Advantages

  • Uses public Kotlin constructors for type-safe brush definition.
  • Enables complex, organic stroke behaviors through procedural noise and response nodes.
  • Supports advanced texture mapping without manual bitmap shader implementation.
  • Provides a consistent, documented workflow for brush structure and behavior.
  • Avoids common antipatterns like manual Bézier smoothing or raw proto builders.

Usage examples

“How do I create a custom pressure-sensitive pen brush?”
The agent will provide a Kotlin code snippet using BrushFamily, BrushCoat, and a BrushBehavior node graph that maps NORMALIZED_PRESSURE to SIZE_MULTIPLIER.
“Help me add a grain texture to my custom brush.”
The agent will guide you through implementing a BrushPaint.TilingTexture, identifying the necessary drawable resource, and registering it in the TextureBitmapStore.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/android/ink-custom-brush-builder/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip ink-custom-brush-builder.zip -d .agents/skills

Documentation by Google LLC

Custom brushes in the Android Ink API are built around the BrushFamily hierarchy:

BrushFamily
├── InputModel (BrushFamily.InputModel.SlidingWindowModel or PASSTHROUGH_MODEL)
└── BrushCoat[] (one or more rendering layers)
    ├── BrushTip (shape: scaleX, scaleY, cornerRounding, rotationDegrees, slantDegrees, pinch)
    │   └── BrushBehavior[] (dynamic response to stylus or touch input)
    │       └── Tree: TargetNode(input = [Operators](input = SourceNode))
    └── BrushPaint (visual appearance)
        ├── SelfOverlap (ANY, ACCUMULATE, or DISCARD)
        ├── TextureLayer[] (BrushPaint.TilingTexture or BrushPaint.StampingTexture)
        └── BrushPaint.ColorFunction[] (OpacityMultiplier or ReplaceColor)

Create a Brush by combining a custom BrushFamily with a Compose Color, size, and epsilon:

val brush = Brush.createWithComposeColor(
    family = myCustomFamily,
    color = Color.Black,
    size = 10f,
    epsilon = 0.1f,
)

<br />

Version and experimental API requirements :

  • Requires androidx.ink 1.1.0-alpha03 and higher : In 1.0.0 (Stable) and 1.1.0-alpha01-alpha02, BrushFamily(...), BrushCoat, BrushTip, BrushPaint, BrushBehavior, and androidx.ink.brush.behavior.* nodes were @RestrictTo(LIBRARY_GROUP) (in 1.0.0 stable, custom brushes can only be loaded from binary proto streams using BrushFamily.decode). Starting in 1.1.0-alpha03 and higher , programmatic custom brush constructors graduated to public API (BrushPaint.TilingTexture, BrushPaint.StampingTexture, BrushPaint.ColorFunction, BrushFamily.InputModel.SlidingWindowModel, and all behavior nodes).

  • No @OptIn required in 1.1.0-alpha03 and higher : All public custom brush classes and ink-storage BrushFamily serialization APIs (BrushFamily.encode and decode, AndroidBrushFamilySerialization, BrushFamilyDecodeCallback) are unannotated in 1.1.0-alpha03 and higher (ExperimentalInkCustomBrushApi is @RestrictTo(LIBRARY_GROUP) in 1.1.0-alpha05 and higher, and is only required on BrushFamily serialization in 1.0.0 stable).

Workflow and task routing

Follow these conditional instructions based on the requested custom brush task:

  • Step 1 (Dependencies) : When setting up an Android project for programmatic custom brushes, ask user permission before editing build files and verify that androidx.ink:ink-brush, androidx.ink:ink-brush-compose, androidx.ink:ink-storage, and androidx.ink:ink-nativeloader use version 1.1.0-alpha03 or higher in gradle/libs.versions.toml and app/build.gradle.kts.

  • Step 2 (Hierarchy, tip shape, paint, and input smoothing) : When defining BrushFamily and multi-coat BrushCoat layers, configuring BrushTip geometry (scaleX, scaleY, cornerRounding, rotationDegrees, slantDegrees, pinch), setting BrushPaint properties (SelfOverlap, ColorFunction), or smoothing stroke input with BrushFamily.InputModel.SlidingWindowModel, you MUST follow brush-structure.md. For baseline Brush creation or 1.0.0 resource loading, review Brush APIs.

  • Step 3 (Dynamic stylus and touch behaviors) : When making a brush respond dynamically to stylus pressure, tilt, speed, direction, or procedural noise using BrushBehavior node trees (SourceNode, DampingNode, NoiseNode, ResponseNode, TargetNode, PolarTargetNode), you MUST follow brush-behaviors.md.

  • Step 4 (Textures and serialization) : When adding BrushPaint.TilingTexture or BrushPaint.StampingTexture layers, implementing TextureBitmapStore, or encoding and decoding custom BrushFamily definitions (BrushFamily.encode and decode, AndroidBrushFamilySerialization, BrushFamilyDecodeCallback), you MUST follow textures-and-serialization.md. Inform the user which texture image files (such as app/src/main/res/drawable-nodpi/pencil_grain.png) to add to their project and register in TextureBitmapStore.

  • Step 5 (Complete brush recipes) : When building a complete pressure pen, calligraphy nib, shading pencil, watercolor wash, or multi-coat shadow brush from scratch, start from the copy-ready implementations in examples.md.

  • Compose drawing surface, eraser, or persistence : For Compose drawing surface setup, InProgressStrokes wet and dry rendering, geometry-based erasing, or Room stroke persistence, suggest the ink-app-builder skill.

Antipatterns

  • NEVER use raw ink.proto.* builders to construct brushes---always use the public Kotlin constructors (BrushFamily, BrushCoat, BrushTip, BrushPaint, BrushBehavior from androidx.ink.brush.*).

  • NEVER manually scale stroke width in a touch listener for pressure or tilt sensitivity---use BrushBehavior mapping SourceNode.Source.NORMALIZED_PRESSURE or TILT_IN_RADIANS to TargetNode.Target.SIZE_MULTIPLIER or WIDTH_MULTIPLIER.

  • NEVER use manual Canvas bitmap stamping or BitmapShader for textured brushes---use BrushPaint.TilingTexture or BrushPaint.StampingTexture with a TextureBitmapStore.

  • NEVER use BlendMode.SRC_OVER on the final (or only) TextureLayer ---use BlendMode.MODULATE, DST_IN, DST_OUT, SRC_ATOP, or SRC_IN so edge anti-aliasing and OPACITY_MULTIPLIER behaviors aren't overridden.

  • NEVER serialize BrushFamily as JSON, Gson, Moshi, or Parcelable ---always use BrushFamily.encode and BrushFamily.decode or AndroidBrushFamilySerialization from androidx.ink.storage.

  • NEVER implement manual Bézier (quadTo, cubicTo) smoothing ---configure BrushFamily.InputModel.SlidingWindowModel for input smoothing and DampingNode for behavior smoothing.

  • NEVER use Random.nextFloat in draw loops for organic stroke wobble---attach a NoiseNode varied over stroke distance in BrushBehavior.

Files

references/brush-structure.md

Reference for defining BrushFamily and BrushCoat hierarchies, configuring BrushTip geometry and BrushPaint blending, and tuning InputModel stroke smoothing (androidx.ink 1.1.0-alpha03 and higher).

BrushFamily and BrushCoat hierarchy

graph TD
    BF["BrushFamily"]
    C0["BrushCoat[0]"]
    C1["BrushCoat[1] ..."]
    T0["BrushTip"]
    P0["BrushPaint[]"]
    BB["BrushBehavior[]"]
    TP["Tip Properties (scaleX, scaleY, cornerRounding, slantDegrees, pinch, rotationDegrees)"]
    SO["SelfOverlap"]
    CF["BrushPaint.ColorFunction[]"]
    TL["TextureLayer[] (TilingTexture / StampingTexture)"]

    BF --> C0
    BF --> C1
    C0 --> T0
    C0 --> P0
    T0 --> TP
    T0 --> BB
    P0 --> SO
    P0 --> CF
    P0 --> TL
LevelTypeRole
BrushFamilyBrushFamilyTop-level immutable brush definition containing one or more BrushCoat layers and an InputModel.
BrushCoatBrushCoatSingle rendering pass with one BrushTip and either paint: BrushPaint or a prioritized fallback list paintPreferences: List<BrushPaint>. Multiple BrushCoat entries in BrushFamily.coats composite from index 0 (bottom) upward.
BrushTipBrushTipGeometric mark shape at each point (scaleX, scaleY, cornerRounding, slantDegrees, pinch, rotationDegrees) plus dynamic BrushBehavior node trees.
BrushPaintBrushPaintVisual appearance (SelfOverlap, BrushPaint.ColorFunction list, and BrushPaint.TilingTexture or StampingTexture layers).
Construct and copy BrushFamily and BrushCoat

Use the multi-coat BrushFamily(coats = listOf(...)) constructor or the single-coat BrushFamily(tip = ..., paint = ...) shortcut, and derive variants with .copy(...) (BrushPaint doesn't provide copy):

val singleCoatFamily = BrushFamily(
    tip = BrushTip(scaleX = 1f, scaleY = 1f, cornerRounding = 1f),
    paint = BrushPaint(selfOverlap = SelfOverlap.ANY),
)

val multiCoatFamily = BrushFamily(
    coats = listOf(
        // Coat 0: Wider semi-transparent shadow coat rendered underneath
        BrushCoat(
            tip = BrushTip(scaleX = 1.3f, scaleY = 1.3f, cornerRounding = 1f),
            paint = BrushPaint(
                selfOverlap = SelfOverlap.DISCARD,
                colorFunctions = listOf(BrushPaint.ColorFunction.OpacityMultiplier(0.15f)),
            ),
        ),
        // Coat 1: Main opaque stroke coat rendered on top
        BrushCoat(
            tip = BrushTip(scaleX = 1f, scaleY = 1f, cornerRounding = 1f),
            paint = BrushPaint(selfOverlap = SelfOverlap.DISCARD),
        ),
    ),
)

val roundedVariant = singleCoatFamily.copy(
    coats = listOf(
        singleCoatFamily.coats.first().let { coat ->
            coat.copy(tip = coat.tip.copy(cornerRounding = 0.5f))
        }
    ),
)

<br />

BrushTip geometry configuration

PropertyType and defaultRange and description
scaleX, scaleYFloat = 1fHorizontal and vertical tip scale multiplied by Brush.size (>= 0f; at least one must be > 0f).
cornerRoundingFloat = 1f0f = sharp rectangle or parallelogram; 1f = fully rounded circle or pill.
slantDegreesFloat = 0fStatic shear angle in degrees ([-90f, 90f]) applied before rotationDegrees.
pinchFloat = 0fPinches top corners together (0f = rectangle, 1f = triangle).
rotationDegreesFloat = 0fStatic rotation offset in degrees (note: BrushTip static angles use degrees, whereas BrushBehavior dynamic angles use radians).
particleGapDistanceScaleFloat = 0fDistance between discrete stamp particles as a multiple of brush size (0f = continuous stroke).
particleGapDurationMillisLong = 0LTime interval in ms between discrete stamp particles (0L = continuous stroke).
behaviorsList<BrushBehavior> = emptyList()Dynamic BrushBehavior node graphs attached to this tip.
BrushTip shape examples (calligraphy nib and flat marker)
// Narrow angled calligraphy nib (static angle in degrees)
val calligraphyTip = BrushTip(
    scaleX = 0.3f,
    scaleY = 1.0f,
    cornerRounding = 0.2f,
    rotationDegrees = 45f,
)

// Wide flat marker tip
val markerTip = BrushTip(
    scaleX = 2.0f,
    scaleY = 0.5f,
    cornerRounding = 0.4f,
)

<br />

BrushPaint blending and ColorFunction

SelfOverlap modes

SelfOverlap controls how regions where a single stroke crosses itself blend during rendering:

ModeBehavior and renderer compatibility
SelfOverlap.ANY (default)Uses ACCUMULATE (CanvasMeshRenderer) on Android 14 (API level 34) and higher hardware Canvas, or DISCARD (CanvasPathRenderer) on Android 13 (API level 33) and lower or software Canvas(bitmap). Required whenever a coat uses per-vertex opacity (OPACITY_MULTIPLIER) or color BrushBehavior instances.
SelfOverlap.ACCUMULATEAccumulates opacity where a translucent stroke crosses itself. Requires CanvasMeshRenderer (Android 14 (API level 34) and higher hardware Canvas); rejected by CanvasPathRenderer unless a fallback BrushPaint is provided in BrushCoat.paintPreferences.
SelfOverlap.DISCARDRenders a flat uniform-opacity outline (CanvasPathRenderer). Incompatible with BrushPaint.StampingTexture and per-vertex opacity or color BrushBehavior instances on the same BrushCoat.
BrushPaint.ColorFunction (OpacityMultiplier and ReplaceColor)

Apply static coat opacity or replace a coat's color (such as a fixed black shadow coat) using BrushPaint.ColorFunction. Never call the internal ReplaceColor.withComposeColor---use withColorLong or withColorIntArgb:

val translucentPaint = BrushPaint(
    selfOverlap = SelfOverlap.ANY,
    colorFunctions = listOf(
        BrushPaint.ColorFunction.OpacityMultiplier(0.7f),
    ),
)

val fixedBlackShadowPaint = BrushPaint(
    selfOverlap = SelfOverlap.DISCARD,
    colorFunctions = listOf(
        BrushPaint.ColorFunction.ReplaceColor.withColorLong(Color.Black.value.toLong()),
        BrushPaint.ColorFunction.OpacityMultiplier(0.2f),
    ),
)

<br />

InputModel and stroke smoothing (SlidingWindowModel)

BrushFamily.inputModel smooths raw touch and stylus points before they reach the behavior graph:

  • BrushFamily.InputModel.SlidingWindowModel : Takes (windowDurationMillis, upsamplingFrequencyHz), applying a moving-average window (windowDurationMillis, default 20L ms; typical range 10L to 50L ms) and temporal upsampling (upsamplingFrequencyHz, default 180 Hz, or 0 to disable). BrushFamily.InputModel.DEFAULT_INPUT_MODEL uses 20L ms and 180 Hz.

  • BrushFamily.InputModel.PASSTHROUGH_MODEL: Bypasses smoothing and upsampling; reserve strictly for synthetic or pre-modeled input streams.

Combine SlidingWindowModel (for path smoothing) with a DampingNode in BrushBehavior (for dynamic property smoothing such as pressure):

/**
 * Creates a custom [BrushFamily] configured for smooth, low-jitter strokes.
 *
 * @param windowDurationMillis Sliding-window duration in milliseconds (default 30ms)
 *   controlling input path smoothing versus latency.
 * @param upsamplingFrequencyHz Target upsampling frequency in Hz (default 180Hz)
 *   for smooth curve subdivision.
 */
fun createSmoothBrushFamily(
    windowDurationMillis: Long = 30L,
    upsamplingFrequencyHz: Int = 180,
): BrushFamily {
    return BrushFamily(
        coats = listOf(
            BrushCoat(
                tip = BrushTip(
                    scaleX = 1f,
                    scaleY = 1f,
                    cornerRounding = 1f,
                    behaviors = listOf(
                        BrushBehavior(
                            terminalNode = TargetNode(
                                target = TargetNode.Target.SIZE_MULTIPLIER,
                                targetModifierRangeStart = 0.5f,
                                targetModifierRangeEnd = 1.5f,
                                input = DampingNode(
                                    dampOver = ProgressDomain.TIME_IN_SECONDS,
                                    strength = 0.15f,
                                    input = SourceNode(
                                        source = SourceNode.Source.NORMALIZED_PRESSURE,
                                        sourceValueRangeStart = 0f,
                                        sourceValueRangeEnd = 1f,
                                        sourceOutOfRangeBehavior = OutOfRange.CLAMP,
                                    ),
                                ),
                            ),
                        ),
                    ),
                ),
                paint = BrushPaint(selfOverlap = SelfOverlap.ANY),
            ),
        ),
        inputModel = BrushFamily.InputModel.SlidingWindowModel(
            windowDurationMillis = windowDurationMillis,
            upsamplingFrequencyHz = upsamplingFrequencyHz,
        ),
    )
}

<br />

Common pitfalls

  • Confusing BrushFamily.coats with BrushCoat.paintPreferences : Multiple BrushCoat entries render on top of each other as layers; multiple BrushPaint entries in paintPreferences are fallback alternatives where the renderer draws only the first compatible BrushPaint.

  • Mixing degrees and radians : BrushTip static angles (rotationDegrees, slantDegrees) use degrees (45f), while BrushBehavior dynamic targets (ROTATION_OFFSET_IN_RADIANS, SLANT_OFFSET_IN_RADIANS) and sources (TILT_IN_RADIANS) use radians ((Math.PI / 4).toFloat()).

  • Combining SelfOverlap.DISCARD with opacity or color BrushBehavior instances : DISCARD forces CanvasPathRenderer, which ignores per-vertex opacity and color behaviors. Use SelfOverlap.ANY instead.

  • Setting windowDurationMillis over 50L ms: Excessive smoothing windows introduce noticeable stylus lag.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Node.js

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Google LLC
Publisher
Android (Google) (Official)
Distributed by
Android (Google)
Source
android/skills · jetpack-compose/ink/ink-custom-brush-builder · commit bf68e2d
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.txt)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Google LLC or Android (Google).

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download ink-custom-brush-builder.zip