Clears the cells of the quadrille according to a bitboard passed as a JavaScript BigInt
. Each 1
bit in the binary representation corresponds to a cell to be cleared (set to null
). The bitboard is read in row-major order, using big-endian by default.
To use little-endian ordering instead, pass true
as the second argument.
Example #
(click to toggle clearing the smiley pattern)
code
Quadrille.cellLength = 50;
let quadrille;
let cleared = false;
const SMILEY = 0b0000000_0110110_0001000_0001000_0100010_0011100_0000000n;
function setup() {
createCanvas(350, 350);
quadrille = createQuadrille(7, 7);
quadrille.fill(color('black')); // Fill entire board
}
function draw() {
background('lemonchiffon');
drawQuadrille(quadrille);
}
function mousePressed() {
cleared ? quadrille.fill(color('black')) : quadrille.clear(SMILEY);
cleared = !cleared;
}
Syntax #
clear(bitboard[, littleEndian])
Parameters #
Param | Description |
---|---|
bitboard | BigInt (or Number): A bitboard whose binary 1 bits indicate the cells to clear |
littleEndian | Optional Boolean: If true , the bitboard is interpreted in little-endian order (default is false ) |