Creates a quadrille of dimensions width × height and randomly places value in exactly order cells (clamped to the board size).
Example#
code
let quadrille;
function setup() {
createCanvas(6 * Quadrille.cellLength, 4 * Quadrille.cellLength);
quadrille = createQuadrille(6, 4, 13, 150);
}
function draw() {
background('orange');
drawQuadrille(quadrille);
}The
orderargument means exactly what the order property means — the number of filled cells: aftercreateQuadrille(6, 4, 13, 150),q.order === 13. Values beyond the board size clamp:createQuadrille(2, 2, 99, value)fills all 4 cells.
To define different values in
createQuadrille(width, height, order, value), refer to createQuadrille(jagged_array).
Syntax#
createQuadrille(width, height, order, value)
Parameters#
| Param | Description |
|---|---|
width | Number: The total number of columns for the quadrille |
height | Number: The total number of rows for the quadrille |
order | Number: The number of cells to fill with value — the resulting order property (clamps to width × height) |
value1 | Any: valid JavaScript value, with null representing empty cells |