Build paint stacks and gradients
Control a contour's color spatially with a ramp or uniformly with layered paints.
Use a gradient when position within a geometry should determine the color. Use ordered paints when multiple color contributions should cover the same region. A fill has one ordered list of paint elements, each containing one paint value. Sibling strokes follow the same geometry after the fill. Paint and stroke rules
In the runnable two-swatch scene, the outlined left swatch has a linear gradient in userSpaceOnUse units. Its ramp runs from navy at (24, 32) to teal at (80, 32), with endpoint colors covering the rest of the shape. The middle of the ramp is at x = 52. Change x2 to 96 to move that midpoint to x = 60. The contour and dark outline keep their positions.
The right swatch layers translucent teal (#4ABCC080) over solid navy (#193661FF). At (144, 32) the combined color is approximately #327991FF. Reverse those two paints and that pixel becomes the opaque navy, since the navy now covers the teal.
For a ramp tied to the geometry’s size, use bounds-relative coordinates. Use a stop track to animate the color or position of one point on the ramp, or key drawable opacity to fade the entire assembled swatch. The preview used for these samples supports solid stacks and a single user-space linear or radial gradient. Gradient units and stops · Stop animation · Preview support
Examples
Download the complete .nothing source · Source on GitHub
Rendered with ncf-preview at 208 × 64.

<scene width="208" height="64">
<shape>
<rect anchor-u="0" anchor-v="0" offset-x="8" offset-y="8" width="88" height="48" corner-radius="12"/>
<fill>
<paint>
<gradient type="linear" gradientUnits="userSpaceOnUse" x1="24" y1="32" x2="80" y2="32">
<stop offset="0" stop-color="#193661FF"/>
<stop offset="1" stop-color="#4ABCC0FF"/>
</gradient>
</paint>
</fill>
<stroke stroke-width="2"><paint><solid color="#122947FF"/></paint></stroke>
</shape>
<shape>
<rect anchor-u="0" anchor-v="0" offset-x="112" offset-y="8" width="88" height="48" corner-radius="12"/>
<fill>
<paint><solid color="#193661FF"/></paint>
<paint><solid color="#4ABCC080"/></paint>
</fill>
</shape>
</scene>