Function

@once

Evaluate the argument once and reuse the result for every cell. Random values inside are drawn a single time instead of once per cell.

Syntax

  • @once(<value>)

Each call site caches its own value for the duration of one render. The same effect can be had by declaring a custom property on :doodle, but @once keeps the value in place.

Examples

One hue for the whole grid, varying lightness per cell:

@grid: 6 / 60vmin _1px;
background: hsl(@once(@r(360)), 70%, @r(30%, 80%));

The same shape on every cell, chosen at random once:

@grid: 4 / 60vmin _2px;
background: #000;
@shape: @once(@p(star, heart, hexagon, drop));
rotate: @r(360deg);

See also