createQuadrille(width, bigint, value)

Converts a bigint to a quadrille, filling cells corresponding to 1 bits in the bigint’s binary representation with the given value. The number of columns is set by width.

Example #

code
Quadrille.cellLength = 200;
let quadrille;

function setup() {
  createCanvas(600, 400);
  /*
  | 5 | 4 | 3 |
  | 2 | 1 | 0 |
  (0)2⁰ + (1)2¹ + (0)2² + (1)2³ + (1)2⁴ + (1)2⁵ = 58
  */
  quadrille = createQuadrille(3, 58n, color('blue'));
}

function draw() {
  background('orange');
  drawQuadrille(quadrille);
}

This example uses a bitboard to fill the quadrille. The binary form of 58 is 111010, where each bit corresponds to a cell in the quadrille:

  • A 1 bit means the cell is filled.
  • A 0 bit means the cell is empty.
    The bits are read from bottom to top and left to right, as shown below:
| 5 | 4 | 3 |
| 2 | 1 | 0 |
(0)2⁰ + (1)2¹ + (0)2² + (1)2³ + (1)2⁴ + (1)2⁵ = 58
To define different values in createQuadrille(width, bigint, value), refer to createQuadrille(jagged_array).

Syntax #

createQuadrille(width, bigint, value)

Parameters #

ParamDescription
widthNumber: The total number of columns for the quadrille
bigintBigInt (or Number): A bigint whose binary representation will determine the filled cells in the quadrille
valueAny: valid JavaScript value, with null representing empty cells