vidmake v0.2.1
Download

Docs/StylePage 31 / 45

Colors and gradients

Every color syntax vidmake accepts (hex, rgb(), hsl(), oklch(), oklab(), names), theme colors, linear and radial gradients with all their options, animated gradient angles, and gradients on text and strokes.

View .md Ask Claude Ask ChatGPT

Anywhere vidmake asks for a color you can write it the way you would in CSS. Fields that take a paint (fill, stroke, text background, a span's fill, captions highlight, and the composition background) also accept a gradient.

#Color syntax

syntaxexamplenotes
#rgb, #rgba"#fa0", "#fa08"short hex, each digit doubled
#rrggbb, #rrggbbaa"#c92a26", "#161412cc"the last pair is alpha (cc ≈ 80%)
rgb(), rgba()"rgb(201, 42, 38)", "rgba(0, 0, 0, 0.5)"0..255 or percentages; alpha 0..1
hsl(), hsla()"hsl(2, 68%, 47%)", "hsla(2, 68%, 47%, 0.5)"hue in degrees; saturation and lightness with %
oklch()"oklch(62% 0.19 260)", "oklch(0.62 0.19 260 / 50%)"lightness (% or 0..1), chroma, hue in degrees, optional / alpha. Perceptually even: steps in lightness look even, and hues at the same lightness look equally bright
oklab()"oklab(70% 0.1 -0.1)"lightness, then the a (green–red) and b (blue–yellow) axes, optional / alpha
CSS names"white", "teal", "gold", "cornflowerblue"the classic SVG/CSS named colors
transparent, none"transparent"fully transparent
array[201, 42, 38], [1, 0.5, 0, 0.8][r, g, b] or [r, g, b, a], see below

Arrays use 0..255 for the color channels when any of r, g or b is above 1, and 0..1 otherwise; alpha is always 0..1 and defaults to 1. So [255, 128, 0] and [1, 0.5, 0] are the same orange, but [1, 1, 1] is white, not almost-black.

"fill": null (or "stroke": null) turns that paint off. Shapes and text default to a white fill and no stroke; arc and line default to a white stroke instead (an arc with "closed": true is filled).

Warning

In a constant color string, hsl() follows CSS and needs % signs: "hsl(40, 50%, 70%)". Without them ("hsl(40, 50, 70)") the values are read as fractions over 100% and you get white. The expression function hsl() is different: it takes plain numbers, "=hsl(40, 50, 70)".

oklch() and oklab() are converted to sRGB; colors outside it are clipped. Some other modern CSS forms are not supported: space-separated rgb(255 0 0 / 50%) and CSS Color 4 names like rebeccapurple. validate reports an invalid color with the field it's in.

#Theme colors

A color used in more than one place belongs in the project's theme: "fill": "$color.accent". Theme colors can alias each other with an alpha, "{color.ink}/60%", and change per mode.

#Animated and computed colors

Colors animate like numbers, with keyframes or a tween, blending red, green, blue and alpha linearly:

json
"fill": [[0, "#c92a26"], ["1s", "#4a4640", "easeInOut"]]"stroke": { "from": "#d8d1c1", "to": "#161412", "duration": "2s", "repeat": "pingpong" }

An expression can compute a color per frame or per copy:

json
"fill": "=hsl(i * 30 + t * 60, 60, 70)""fill": "=pick(beats, ['#161412', '#1f5fb0', '#c92a26'])""fill": "=lerp('#e9e4d8', '#4a4640', p)""fill": "=rgb(255, 128 + 127 * sin(t), 0)"

#Gradients

A gradient is an object with a type. Its coordinates are relative to the layer's own box, so the same gradient fits a small button and a full-screen background alike.

json
{ "type": "linear", "angle": 90, "stops": ["#c92a26", "#1f5fb0"] }{ "type": "linear", "angle": 160, "stops": [[0, "#e9e4d8"], [0.55, "#c92a26"], [1, "#161412"]] }{ "type": "radial", "center": [0.3, 0.25], "radius": 0.9, "stops": ["#fbf9f4", "#1f5fb0", "#161412"] }
00:00.0 · f 000
Gradient paints: two stops, positioned stops, radial, and an animated angleDownload
colors-gradients.jsonjson
{  "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }],  "compositions": [{    "id": "gradients", "description": "Gradient paints: two stops, positioned stops, radial, and an animated angle",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "two", "type": "rect", "x": 220, "y": 330, "width": 240, "height": 300, "cornerRadius": 4,        "fill": { "type": "linear", "angle": 90, "stops": ["#c92a26", "#1f5fb0"] } },      { "id": "stops", "type": "rect", "x": 500, "y": 330, "width": 240, "height": 300, "cornerRadius": 4,        "fill": { "type": "linear", "angle": 160, "stops": [[0, "#e9e4d8"], [0.55, "#c92a26"], [1, "#161412"]] } },      { "id": "radial", "type": "rect", "x": 780, "y": 330, "width": 240, "height": 300, "cornerRadius": 4,        "fill": { "type": "radial", "center": [0.3, 0.25], "radius": 0.9, "stops": ["#fbf9f4", "#1f5fb0", "#161412"] } },      { "id": "spin", "type": "rect", "x": 1060, "y": 330, "width": 240, "height": 300, "cornerRadius": 4,        "fill": { "type": "linear", "angle": { "from": 0, "to": 360, "duration": "4s", "ease": "linear" },                  "stops": ["#161412", "#e9e4d8", "#c92a26"] } },      { "id": "label", "type": "text", "text": "${pick(i, ['linear 90', 'positioned stops', 'radial', 'animated angle'])}",        "font": "JetBrains Mono", "fontSize": 15, "letterSpacing": 2, "uppercase": true, "fill": "#8a857a", "x": 640, "y": 540,        "repeat": { "count": 4, "layout": "row", "spacing": 280 } }    ]  }]}

#Linear

fielddefaultnotes
type"linear"
angle90direction in degrees, like CSS: 0 = towards the top, 90 = towards the right, 180 = down. Animatable
stopsrequiredat least two, see stops

The gradient runs through the center of the box and is sized so the first and last stops land exactly on the box's corners (or edges) for any angle, as in CSS. Beyond the ends the edge colors continue.

#Radial

fielddefaultnotes
type"radial"
center[0.5, 0.5]center as fractions of the box: [0, 0] is the top-left corner
radius0.5radius as a fraction of the box's larger side: 0.5 reaches the middle of the longer edges, about 0.7 reaches the corners of a square
stopsrequiredfrom the center outwards

#Stops

stops is a list of at least two entries. Each entry is either:

  • a color, and the stops are spread evenly: ["#000", "#888", "#fff"] puts them at 0, 0.5 and 1;
  • [offset, color], with offset in 0..1: [[0, "#000"], [0.7, "#123"], [1, "#fff"]];
  • { "offset": 0.7, "color": "#123" } (without offset, the stop gets its evenly spaced position).

Colors in stops can have alpha, which is how you fade something out: ["#c92a26", "#c92a2600"].

#Animating gradients

A linear gradient's angle takes any animation form: keyframes, a tween, a spring or an expression. That's enough for a slowly turning sheen or a light sweep:

json
"fill": { "type": "linear", "angle": { "from": 0, "to": 360, "duration": "4s", "ease": "linear" },          "stops": ["#161412", "#e9e4d8", "#c92a26"] }

The stops and a radial gradient's center and radius are fixed. To move a radial glow, move or scale the layer that carries it, or put the gradient on a larger layer and animate that layer's position behind a mask.

Note

The gradient belongs to the layer's box, so it turns with the layer: rotating a rect with a horizontal gradient rotates the gradient too. To keep the light direction fixed while the shape spins, counter-animate the angle.

#Gradients on text and strokes

A gradient works anywhere a paint does. On a text fill it spans the text box (including padding), on a stroke it follows the outline, and in a rich-text span it colors just that span:

00:00.0 · f 000
Gradients on text fills, on strokes, and on a single rich-text spanDownload
colors-text.jsonjson
{  "fonts": [{ "family": "Schibsted Grotesk", "path": "fonts/SchibstedGrotesk.ttf" }],  "compositions": [{    "id": "text", "description": "Gradients on text fills, on strokes, and on a single rich-text span",    "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea",    "layers": [      { "id": "ring", "type": "arc", "x": 640, "y": 330, "width": 620, "strokeWidth": 10, "rotation": "=t * 90",        "endAngle": { "keys": [[0, 0], ["2s", 360]], "ease": "easeInOutCubic", "repeat": "pingpong" },        "stroke": { "type": "linear", "angle": 0, "stops": ["#1f5fb0", "#c92a26", "#f4f1ea"] } },      { "id": "title", "type": "text", "text": "Spot color", "font": "Schibsted Grotesk", "fontWeight": 860, "fontSize": 100,        "letterSpacing": -4, "y": 310,        "fill": { "type": "linear", "angle": { "from": 60, "to": 300, "duration": "4s", "ease": "linear" },                  "stops": ["#161412", "#1f5fb0", "#c92a26"] } },      { "id": "line", "type": "text", "font": "Schibsted Grotesk", "fontWeight": 500, "fontSize": 32, "fill": "#4a4640", "y": 470,        "text": ["fills, strokes and ", { "text": "single spans", "fontWeight": 800, "fill": { "type": "linear", "angle": 90, "stops": ["#1f5fb0", "#c92a26"] } }] }    ]  }]}
json
"fill": { "type": "linear", "angle": 60, "stops": ["#161412", "#1f5fb0", "#c92a26"] }"stroke": { "type": "linear", "angle": 0, "stops": ["#1f5fb0", "#c92a26", "#f4f1ea"] }"text": ["fills, strokes and ", { "text": "single spans", "fill": { "type": "linear", "angle": 90, "stops": ["#1f5fb0", "#c92a26"] } }]

#Backgrounds

The composition's background is a paint over the whole frame. Leave it out for a transparent background: .webm, .mov, .png and .gif output keep the alpha channel (see Rendering).

json
"background": { "type": "radial", "center": [0.5, 0.4], "radius": 0.9, "stops": ["#fbf9f4", "#e9e4d8"] }

For a background that animates, use a full-size rect as the first layer instead: a rect without width and height fills its parent, and its fill can be keyframed, tweened or computed.

#Where colors are used

fieldtakes
fill, strokepaint: color or gradient
text background, span fillpaint
captions highlightpaint
composition backgroundpaint
shadow.color, glow.colorcolor (animatable)
particle emitter.colorsa list of plain colors