Brush

fun interface Brush

A fill resolved against the size of what it decorates - what background paints under a component's content and what border strokes its edge with. It is asked for its paint each time the component paints, at the size its decorated box stands at then, with that box's top-left corner as the origin.

The gradients below compare structurally, so a chain rebuilt from unchanged values declares the same fill and nothing repaints. of wraps a paint of the caller's own and compares it by identity - hoist such a paint into a remember. A lambda passed where this interface is expected has identity equality and needs the same treatment.

A gradient with a single stop, and one whose span collapses to nothing because the component has no width or height along its axis, both resolve to a solid of the last stop's color.

A gradient holds each stop's fraction between the stop before it and 1f, and the first stop's between 0f and 1f, as androidx's gradients do.

Types

Link copied to clipboard
object Companion

The brushes built from values: the gradients, and one built from a java.awt.Paint.

Functions

Link copied to clipboard
abstract fun paint(width: Int, height: Int): Paint

The paint this brush takes at width x height, with the decorated box's top-left corner as the origin.