Function

@palette

A list of colors that go together, as oklch() values separated by commas. The doodle's seed picks the palette, so every render gets a new one. Click the example to see another:

@grid: 5x1 / 60vmin 20vmin;
background: @pn(@palette());

Syntax

  • @palette([<count>])
  • @palette([<count>], <color>)

The count and the color are told apart by what they look like, so they can come in either order.

count
How many colors, from 1 to 256. Defaults to 5.
color
A color to build the palette around. Any CSS color works, such as tomato, oklch(70% .12 250) or var(--brand).

Using the colors

The list goes where a list of values does. @p picks one at random for each cell:

@grid: 80x1 / 60vmin;
clip-path: @tile.voronoi(gap: .8);
background: @p(@palette());

A gradient blends them:

@grid: 1 / 60vmin;
background: radial-gradient(@palette(3));

@stripe turns them into bands:

@grid: 1 / 60vmin;
border-radius: 50%;
background: conic-gradient(@stripe(@palette(6)));

One palette per doodle

Every cell gets the same list, and so does :doodle. Calling @palette takes nothing from the random values of @r and @p, so adding it to a doodle leaves the rest of it as it was. Here :doodle takes @palette(1), the ground, as its background:

@grid: 12 / 60vmin;
:doodle {
  background: @palette(1);
}
margin: 15%;
border-radius: 50%;
background: @p(@palette(4));

Around a color

Given a color, the palette has it second, exactly as written, after a ground that stands out from it:

@grid: 5x1 / 60vmin 20vmin;
background: @pn(@palette(5, #e6437d));

How the colors are chosen

The first color is a ground: a paper white, an ink dark or a muted middle, lightly tinted. The second is the ink, which stands out from it, though it is not checked for text contrast. The colors after it keep apart from the ones before, often in a hue the palette already has. A larger count keeps the smaller one as its start: @palette(3) is the first three colors of @palette(5).

@grid: 9x1 / 60vmin 20vmin;
background: @pn(@palette(9));

Every color is kept inside sRGB, the range any screen can show.

See also