Color & Effects

Gradients

A gradient is a paint like a color, so it goes anywhere a color goes: a fill, one of several fills, a stroke, the letters of a text. Nox has four kinds and three ways to mix the colors between stops. The mixing is the part most designs get wrong, and the easiest to fix.

The same three stops as a linear, radial, angular and diamond gradient
The same three stops as a linear, radial, angular and diamond gradient

The four kinds#

KindIn the toolsUse it for
Linear"gradient": "linear"Buttons, headers, sheens, fades to transparent
Radial"gradient": "radial"Glows, spotlights, a bloom of color in a corner
Angular"gradient": "angular"Rings, dials, color wheels: the colors go round the middle, clockwise
Diamond"gradient": "diamond"A sharp, faceted light; a badge or a gem
By hand
  1. Click a fill's or a stroke's swatch, and choose Linear, Radial, Angular or Diamond at the top of the picker.
  2. The bar under it has a knob for each stop. Click a knob to select it; the square, the bars, the hex value and the opacity are then that stop's.
  3. Drag a knob to move its stop. Click the bar where there is no knob to add a stop with the color that was there. The − button or Delete removes the selected stop (a gradient keeps at least two).
  4. For a linear gradient, type the Angle in degrees.
The gradient picker: the stops bar, the angle, and the selected stop's color
The gradient picker: the stops bar, the angle, and the selected stop's color

Changing one kind into another keeps the stops, so you can try all four in a few clicks.

Stops, angle, from and to#

stops is a list of colors, spread evenly, or a list of {"offset": 0.3, "color": "#..."} placed where you say, from 0 to 1. A stop's color may be transparent (#FF7AC600), which is how a gradient fades into what is under it.

Where a gradient runs is given one of two ways:

  • angle, for a linear gradient, in degrees as CSS has them: 180 runs from the top down (the default), 90 from left to right, 135 from the top left to the bottom right.
  • from and to, two points in units of the node's box: [0, 0] is its top-left corner, [1, 1] its bottom-right. For a radial or diamond gradient, from is the middle and to is how far it reaches. Nox stores an angle as these two points, so get_nodes reports from and to either way.

In the picker you set a linear gradient's angle; the middle and reach of the other kinds are set through the tools.

With an agent
Fill the hero card with a soft spotlight: warm #FFB36B in the middle, #FF5C8A halfway, #6B5BFF at the edge. Mix it in OKLab.

The agent calls update_nodes with a fill for the card:

{
  "changes": [{
    "id": "4:2",
    "fill": {"gradient": "radial", "from": [0.5, 0.5], "to": [1, 1], "mixing": "oklab",
             "stops": [{"offset": 0, "color": "#FFB36B"}, {"offset": 0.5, "color": "#FF5C8A"}, {"offset": 1, "color": "#6B5BFF"}]}
  }]
}

Mixing: sRGB, OKLab, OKLCH#

Between two stops Nox works out the colors in one of three ways, set by mixing:

  • srgb, the default, mixes the raw red, green and blue numbers. Between two bright colors on opposite sides of the wheel, blue and orange or cyan and pink, the middle sinks to a muddy gray.
  • oklab mixes in a space made to match how bright colors look. The middle stays as light as its ends and the gradient looks even from end to end.
  • oklch goes round the hue wheel instead of straight across it, so a blue-to-orange gradient passes through violet and pink and stays vivid all the way.
The same two pairs of colors mixed in sRGB, OKLab and OKLCH
The same two pairs of colors mixed in sRGB, OKLab and OKLCH

Use oklab when a gradient should feel calm and even, oklch when it should feel saturated and alive. Keep srgb for gradients from a color to the same color transparent, where there is no middle to lose. The picker has no switch for mixing: set it through the tools, as in the example above.

Gradient text and gradient strokes#

A text's fill is a paint like any other, so the letters themselves can carry a gradient. A stroke can too: an outline button with a gradient edge, a ring with an angular one, a divider that fades at both ends.

A gradient on the letters, a gradient stroke on a button, an angular stroke on a ring, and a rule that fades at both ends
A gradient on the letters, a gradient stroke on a button, an angular stroke on a ring, and a rule that fades at both ends
With an agent
Set "Ship calmer." in Geist Bold 64 with a mint-to-blue-to-lilac gradient across the letters, and under it an outline button whose 2 pt edge has the same gradient.

The agent calls create_nodes:

{
  "nodes": [
    {"kind": "text", "name": "Headline", "x": 0, "y": 0, "text": "Ship calmer.", "font_family": "Geist", "font_size": 64, "font_weight": 700, "letter_spacing": -2,
     "fill": {"gradient": "linear", "angle": 90, "mixing": "oklch", "stops": ["#7CF5C4", "#6BA8FF", "#C58BFF"]}},
    {"kind": "rectangle", "name": "Outline button", "x": 0, "y": 110, "width": 190, "height": 56, "corner_radius": 28, "fill": "#1B1E26",
     "stroke": {"gradient": "linear", "angle": 90, "mixing": "oklch", "stops": ["#7CF5C4", "#6BA8FF", "#C58BFF"]},
     "stroke_width": 2, "stroke_align": "inside"}
  ]
}

On a long headline, keep the gradient's ends close in lightness so every letter reads against the background, and check the lightest one with the picker's Contrast.

Mesh-like backdrops#

A soft wash of several colors, the kind behind a hero or a sign-in screen, is not one gradient. Make it from a few ellipses in a frame with a dark fill, each a solid color at 75–95% opacity, each with a large layer_blur (50–60 on a frame 300 wide). Turn on the frame's clipping so the blurred edges stop at its border, and put your words on top.

Four colored ellipses on #0E1020, then the same ellipses blurred into a backdrop with a headline over it
Four colored ellipses on #0E1020, then the same ellipses blurred into a backdrop with a headline over it

Move the ellipses to move the light; change one fill to change the mood. Four or five shapes are enough. Many large blurs in one frame cost time on every redraw, so for a single glow use a radial gradient that fades to transparent instead (see Blur and glass).

Note

A gradient on a path is measured from the node's own origin, its 0, 0, not from where the drawing begins. A path whose data starts at M50 0 has an empty band on its left, and the gradient begins in that band. Start path data at 0 0 and place the node with x and y, and the gradient runs across the shape you see.