@random
Cells picked at random, by probability or by count.
Syntax
- @random { }
- @random(<ratio>) { }
- @random(<count>) { }
- @random not (<ratio>) { }
- ratio
- A number below
1, the chance that each cell is picked. Default.5. - count
- A number of
1or more: exactly this many cells are picked.
The argument may be an expression over the cell variables, so the probability can vary across the grid.
It reads custom properties without their -- too, so --n: 3; @random(n) picks three cells.
Where the value reaches 1 it is read as a count, so keep such a probability below 1.
Each occurrence of the selector draws its own cells.
Examples
@grid: 5 / 60vmin _1px;
@content: @i;
@random {
background: #000;
color: #fff;
} Exactly two cells:
@grid: 5 / 60vmin _1px;
@content: @i;
@random(2) {
background: #000;
color: #fff;
} Independent draws for each rule:
@grid: 16 / 60vmin;
@random {
border-top: 1px solid #000;
}
@random {
border-left: 1px solid #000;
}
@random(.2) {
background:
linear-gradient(#000, #000)
50% 50% / @r(80%) @lr
no-repeat;
} A probability that grows towards the bottom of the grid:
@grid: 24 / 60vmin _1px;
@random((y - 1) / Y) {
background: #000;
}