androidx.compose.ui.graphics

MeshGradientPainterSince 1.12

Class · from org.jetbrains.compose.ui:ui:1.12.2

No hand-written docs yet.

A MeshGradient is a 2D grid of patches defined by vertices. Each vertex has a position, color, and four optional Bezier control points (tangents) that define the curvature of the edges connecting neighboring vertices.

class MeshGradientPainter(
    rows: Int,
    columns: Int,
    hasBicubicColor: Boolean = false,
    block: MeshGradientScope.() -> Unit,
) : Painter

Is a

How to get one

Create it

Library docs

A MeshGradient is a 2D grid of patches defined by vertices. Each vertex has a position, color, and four optional Bezier control points (tangents) that define the curvature of the edges connecting neighboring vertices.

Grid Dimensions: For a given rows and columns (representing the number of patches), there are a total of (rows + 1) * (columns + 1) vertices. For example, a 1x1 mesh consists of 4 vertices forming a single rectangular patch.

Coordinate System: All positions and Bezier offsets use a normalized coordinate system where (0,0) is the top-left and (1,1) is the bottom-right of the drawing bounds.

Bezier Tangents: Bezier control points are provided as an Offset relative to the vertex position. The default value of a Bezier control point is Offset.Unspecified. If a control point is Offset.Unspecified, the renderer automatically infers a tangent based on the neighboring vertices to ensure C1 continuity (smooth transitions) across patches.