createQuadrille(width, height, bitboard, value, littleEndian?)

Creates a quadrille by decoding a bitboard—passed as a JavaScript BigInt—into a fixed-size rectangular quadrille. Each bit in the bitboard determines whether a corresponding cell is filled (1) or empty (0). The number of columns is set by width, and the number of rows is explicitly set by height.

Note

This function lets you control both width and height directly, making it useful for placing bitboard-defined patterns into specific regions of a larger quadrille.

Example 1 — Big-endian (default)

edit, then run

Note

This bitboard places an L shape into a 3×4 quadrille using row-major, big-endian order:

  • Bit 11 → cell (0,0) — top-left
  • Bit 0 → cell (3,2) — bottom-right
MSB (bit 11)
↓
|     |     |     |
|     |  1  |     |
|     |  1  |     |
|     |  1  |  1  |
↑
LSB (bit 0)

Example 2 — Little-endian

edit, then run

Note

Same bitboard (147n) as before, but read in row-major, little-endian order:

  • Bit 0 → cell (0,0) — top-left
  • Bit 11 → cell (3,2) — bottom-right

This results in a flipped L shape:

|  1  |  1  |     |
|     |  1  |     |
|     |  1  |     |
|     |     |     |

This layout matches little-endian rank-file ordering as used in engines like Stockfish.

Warning

The bitboard must be a BigInt (note the n suffix: 147n). A plain Number is dispatched as createQuadrille(width, height, order, value) instead — createQuadrille(3, 4, 147, value) randomly fills the board (147 clamps to all 12 cells) rather than decoding a pattern.

Syntax

createQuadrille(width, height, bitboard, value[, littleEndian])

Parameters

Param Description
width Number: Number of columns in the quadrille
height Number: Number of rows in the quadrille
bitboard BigInt: A bitboard whose binary representation determines which cells are filled
value1 Any: valid JavaScript value, with null representing empty cells
littleEndian Optional Boolean: If true, reads the bitboard in little-endian order (default is false, big-endian)
  1. A plain function value is stored, not called — it becomes a per-cell display routine ({ row, col, options }) => { ... } (see options). To have a function evaluated per cell at creation time — a fresh object or a varied tile per cell — tag it: Quadrille.factory(({ row, col }) => new Object(...)). ↩
What this page's examples use
p5.quadrille
drawQuadrille createQuadrille
p5.js
createCanvas background color

Names the analysis can prove are called, and the line each one is documented on. Local variables and members of an unknown receiver are left out.