export default Quadrille; declare class Quadrille { /** * Library version identifier. * @type {string} */ static VERSION: string; /** * Tags a function as a factory, meaning it should be executed during `fill`. * The function will be called with `{ row, col }` and must return a value * to be stored in the quadrille. Display functions (returning `undefined`) * should not use this. If a non-function is passed, it is returned as-is. * @param {*} fn - A function returning a value to fill cells with, or a direct value. * @returns {Function|*} The same function tagged with `._isFactory = true`, or the value itself. */ static factory(fn: any): Function | any; /** * Declares that a value is a shared singleton to be reused across cells. * Unlike `Quadrille.factory(fn)`, this method is purely semantic and does * not modify the value. It clarifies that the same instance is intended * to be reused when passed to `fill()`, particularly for object values * like class instances. * This is useful for improving code readability and documenting intent. * @example * const elf = Quadrille.singleton(new Unit('Elf', 'blue', '🧝')); * game.fill(elf); // same object used in all cells * @param {*} value - A literal or object to share across multiple cells. * @returns {*} The same value, unmodified. */ static singleton(value: any): any; /** * Default text color. * @type {string} */ static _textColor: string; /** * Sets the text color used when rendering values. * Accepts any valid CSS string or p5 color. * @param {string|*} value */ static set textColor(value: string | any); /** * Gets the current text color. * @returns {string} */ static get textColor(): string; /** * Default text drawing zoom. * @type {number} */ static _textZoom: number; /** * Sets the text zoom scale. Must be a positive number. * @param {number} value */ static set textZoom(value: number); /** * Gets the current text zoom scale. * @returns {number} */ static get textZoom(): number; /** * Default drawing outline. * @type {string} */ static _outline: string; /** * Sets the outline color used to draw cells. * Accepts any valid CSS string or p5 color. * @param {string|*} value */ static set outline(value: string | any); /** * Gets the current outline color. * @returns {string} */ static get outline(): string; /** * Default drawing outline weight. * @type {number} */ static _outlineWeight: number; /** * Sets the outline stroke weight. Must be a non-negative number. * @param {number} value */ static set outlineWeight(value: number); /** * Gets the current outline stroke weight. * @returns {number} */ static get outlineWeight(): number; /** * Default drawing cell length. * @type {number} */ static _cellLength: number; /** * Sets the cell size in pixels. Must be a positive number. * @param {number} value */ static set cellLength(value: number); /** * Gets the current cell size in pixels. * @returns {number} */ static get cellLength(): number; /** * Default background used in sort. * @type {string} */ static _background: string; /** * Sets the background color used in sort(). * Accepts any valid CSS string or p5 color. * @param {string|*} value */ static set background(value: string | any); /** * Gets the background color used in sort(). * @returns {string} */ static get background(): string; /** * Default chess dark squares. * @type {string} */ static _darkSquare: string; /** * Sets the color for dark chessboard squares. * @param {string|*} value */ static set darkSquare(value: string | any); /** * Gets the color for dark chessboard squares. * @returns {string} */ static get darkSquare(): string; /** * Default chess light squares. * @type {string} */ static _lightSquare: string; /** * Sets the color for light chessboard squares. * @param {string|*} value */ static set lightSquare(value: string | any); /** * Gets the color for light chessboard squares. * @returns {string} */ static get lightSquare(): string; /** * Internal FEN β†’ symbol map (Unicode, emoji, image, etc.). * @type {Map} * @private */ private static _chessSymbols; /** * Updates entries in the FEN β†’ symbol mapping. * Accepts either a plain object or a Map. Merges into the current map to support partial updates. * @param {Object|Map} symbols - Entries to merge into the FEN β†’ symbol map. */ static set chessSymbols(symbols: { [x: string]: any; } | Map); /** * Gets a copy of the FEN β†’ symbol map. * @returns {Map} Copy of internal chessSymbols map. */ static get chessSymbols(): Map; /** * Gets a reverse map from symbol to FEN key. * @returns {Map<*, string>} New reverse map (symbol β†’ FEN) */ static get chessKeys(): Map; /** * Returns the bit index (row-major). * Default is big-endian (MSB = top-left). Set `littleEndian = true` for LSB = top-left. * If the cell is out of bounds, logs a warning and returns `undefined`. * @param {number} row * @param {number} col * @param {number} [width=8] * @param {number} [height=8] * @param {boolean} [littleEndian=false] * @returns {number|undefined} The bit index, or undefined if out of bounds. */ static bitIndex(row: number, col: number, width?: number, height?: number, littleEndian?: boolean): number | undefined; /** * Returns the cell position corresponding to a bit index. * Optionally supports little-endian (default: false) layout. * If the bit index is out of bounds, logs a warning. * @param {number|bigint} bitIndex - Bit index to convert. * @param {number} [width=8] - Number of columns in the quadrille. * @param {number} [height=8] - Number of rows in the quadrille. * @param {boolean} [littleEndian=false] - Whether to use little-endian ordering. * @returns {{row: number, col: number}|undefined} The cell position, or undefined if out of bounds. */ static bitCell(bitIndex: number | bigint, width?: number, height?: number, littleEndian?: boolean): { row: number; col: number; } | undefined; /** * Logical AND between two quadrilles. * @param {Quadrille} q1 First quadrille * @param {Quadrille} q2 Second quadrille * @param {number} row Relative row offset from q1 * @param {number} col Relative column offset from q1 * @returns {Quadrille} A new quadrille containing only cells filled in both q1 and q2 */ static and(q1: Quadrille, q2: Quadrille, row: number, col: number): Quadrille; /** * Logical OR between two quadrilles. * @param {Quadrille} q1 First quadrille * @param {Quadrille} q2 Second quadrille * @param {number} row Relative row offset from q1 * @param {number} col Relative column offset from q1 * @returns {Quadrille} A new quadrille containing cells filled in either q1 or q2 */ static or(q1: Quadrille, q2: Quadrille, row: number, col: number): Quadrille; /** * Logical XOR between two quadrilles. * @param {Quadrille} q1 First quadrille * @param {Quadrille} q2 Second quadrille * @param {number} row Relative row offset from q1 * @param {number} col Relative column offset from q1 * @returns {Quadrille} A new quadrille containing cells filled in one, but not both, of q1 and q2 */ static xor(q1: Quadrille, q2: Quadrille, row: number, col: number): Quadrille; /** * Logical difference (q1 minus q2) between two quadrilles. * @param {Quadrille} q1 First quadrille * @param {Quadrille} q2 Second quadrille * @param {number} row Relative row offset from q1 * @param {number} col Relative column offset from q1 * @returns {Quadrille} A new quadrille with cells filled in q1 but not in q2 */ static diff(q1: Quadrille, q2: Quadrille, row: number, col: number): Quadrille; /** * Merges two quadrilles by applying a binary operator to their overlapping cells. * Builds the result memory directly and returns a fresh Quadrille (no ctor call). * @param {Quadrille} q1 * @param {Quadrille} q2 * @param {(a: *, b: *) => *} operator * @param {number} [row] * @param {number} [col] * @returns {Quadrille} */ static merge(q1: Quadrille, q2: Quadrille, operator: (a: any, b: any) => any, row?: number, col?: number): Quadrille; /** * Allocates a heightΓ—width 2D array filled with nulls (never undefined). * @param {number} h * @param {number} w * @returns {Array>} */ static _allocNullMemory(h: number, w: number): Array>; /** * Allocates a Quadrille *without* calling the constructor, mirroring the * fresh defaults of `new Quadrille(p, ...)`. * Usage: * _allocQ(from, h, w) -> creates hΓ—w null-padded memory * _allocQ(from, mem2D) -> wraps provided 2D array * Fresh defaults replicated: * _p: from._p * _cellLength: from.constructor.cellLength * _x: 0 * _y: 0 * _origin: 'corner' * _row/_col: left undefined * @param {Quadrille} from * @param {number|Array>} hOrMem * @param {number} [w] * @returns {Quadrille} */ static _allocQ(from: Quadrille, hOrMem: number | Array>, w?: number): Quadrille; /** * Logical NOT of a quadrille (non-destructive). * Returns a new quadrille where filled/empty status is inverted. * @param {Quadrille} q Input quadrille * @param {*} target Value to fill where the quadrille is empty * @returns {Quadrille} A new quadrille with inverted filled/empty status */ static not(q: Quadrille, target: any): Quadrille; /** * Returns a shifted copy of the given Quadrille. * Shifts all filled cells of `q` by (dRow, dCol) across the grid. * - dRow > 0: shift down; dRow < 0: shift up * - dCol > 0: shift right; dCol < 0: shift left * - wrap = true (default): toroidal wrap-around * - wrap = false: clip at edges (cells falling outside are discarded) * This function is **non-destructive**: the input Quadrille remains unchanged. * @param {Quadrille} q - The Quadrille to shift. * @param {number} dRow - Vertical shift amount. * @param {number} dCol - Horizontal shift amount. * @param {boolean} [wrap=true] - Whether to wrap around the edges. * @returns {Quadrille} A new shifted Quadrille. */ static shift(q: Quadrille, dRow: number, dCol: number, wrap?: boolean): Quadrille; /** * Determines whether a value is considered empty. * @param {*} value * @returns {boolean} */ static isEmpty(value: any): boolean; /** * Determines whether a value is considered filled. * @param {*} value * @returns {boolean} */ static isFilled(value: any): boolean; /** * Checks whether the given value is a boolean. * @param {*} value * @returns {boolean} */ static isBoolean(value: any): boolean; /** * Checks whether the given value is a symbol. * @param {*} value * @returns {boolean} */ static isSymbol(value: any): boolean; /** * Checks whether the given value is a number. * @param {*} value * @returns {boolean} */ static isNumber(value: any): boolean; /** * Checks whether the given value is a BigInt. * @param {*} value * @returns {boolean} */ static isBigInt(value: any): boolean; /** * Checks whether the given value is a string. * @param {*} value * @returns {boolean} */ static isString(value: any): boolean; /** * Checks whether the given value is a p5.Color instance. * @param {*} value * @returns {boolean} */ static isColor(value: any): boolean; /** * Checks whether the given value is a function. * @param {*} value * @returns {boolean} */ static isFunction(value: any): boolean; /** * Checks whether the given value is a p5.Image, p5.Graphics, MediaElement (video), or Framebuffer. * @param {*} value * @returns {boolean} */ static isImage(value: any): boolean; /** * Checks whether the given value is an array. * @param {*} value * @returns {boolean} */ static isArray(value: any): boolean; /** * Checks whether the given value is a generic object (not a color, image, function, or array). * @param {*} value * @returns {boolean} */ static isObject(value: any): boolean; /** * Renders a cell and returns its average RGBA values as a literal object. * @param {Object} [params={}] - Sampling parameters. * @param {*} params.value - Cell content to sample. * @param {p5.Font} [params.textFont] * @param {string} [params.origin='corner'] * @param {Object} [params.options={}] * @param {'p2d'|'webgl'} [params.renderer='p2d'] * @param {Function} [params.imageDisplay] * @param {Function} [params.colorDisplay] * @param {Function} [params.stringDisplay] * @param {Function} [params.numberDisplay] * @param {Function} [params.bigintDisplay] * @param {Function} [params.booleanDisplay] * @param {Function} [params.symbolDisplay] * @param {Function} [params.arrayDisplay] * @param {Function} [params.objectDisplay] * @param {Function} [params.functionDisplay] * @param {Function} [params.tileDisplay] * @param {string|*} [params.background] * @param {number} [params.cellLength] * @param {number} [params.outlineWeight] * @param {string|*} [params.outline] * @param {string|*} [params.textColor] * @param {number} [params.textZoom] * @returns {{ r: number, g: number, b: number, a: number, total: number }} Average color channels and sample size. */ static sample({ value, textFont, origin, options, renderer, imageDisplay, colorDisplay, stringDisplay, numberDisplay, bigintDisplay, booleanDisplay, symbolDisplay, arrayDisplay, objectDisplay, functionDisplay, tileDisplay, background, cellLength, outlineWeight, outline, textColor, textZoom }?: { value: any; textFont?: p5.Font; origin?: string; options?: any; renderer?: "p2d" | "webgl"; imageDisplay?: Function; colorDisplay?: Function; stringDisplay?: Function; numberDisplay?: Function; bigintDisplay?: Function; booleanDisplay?: Function; symbolDisplay?: Function; arrayDisplay?: Function; objectDisplay?: Function; functionDisplay?: Function; tileDisplay?: Function; background?: string | any; cellLength?: number; outlineWeight?: number; outline?: string | any; textColor?: string | any; textZoom?: number; }): { r: number; g: number; b: number; a: number; total: number; }; static _display(params: any): void; /** * Renders a number value using its color equivalent. * @param {Object} params * @param {p5.Graphics} params.graphics - Rendering context. * @param {number} params.value - Numeric value to draw. * @param {number} [params.cellLength=this.cellLength] - Cell size in pixels. */ static numberDisplay({ graphics, value, cellLength }?: { graphics: p5.Graphics; value: number; cellLength?: number; }): void; /** * Renders a BigInt value using numberDisplay after converting to Number. * @param {Object} params * @param {p5.Graphics} params.graphics - Rendering context. * @param {bigint} params.value - BigInt value to render. * @param {number} [params.cellLength=this.cellLength] - Cell size in pixels. * @param {*} [params.textColor=this.textColor] - Fill color for text. * @param {number} [params.textZoom=this.textZoom] - Text size scaling factor. */ static bigintDisplay({ graphics, value, cellLength }?: { graphics: p5.Graphics; value: bigint; cellLength?: number; textColor?: any; textZoom?: number; }): void; /** * Renders a color value by filling the cell. * @param {Object} params * @param {p5.Graphics} params.graphics - Rendering context. * @param {*} params.value - Fill color. * @param {number} [params.cellLength=this.cellLength] - Cell size in pixels. */ static colorDisplay({ graphics, value, cellLength }?: { graphics: p5.Graphics; value: any; cellLength?: number; }): void; /** * Renders a function-based cell using an internal framebuffer in WEBGL mode. * Also serves as the fallback renderer for any object with a `display` function. * In `WEBGL` mode, rendering is performed into a framebuffer object (FBO), * and the result is drawn using `imageDisplay`. The drawing function is * invoked with `options` as its only parameter and `this` bound to the framebuffer's * `p5.Graphics` context (or the object if provided). * In `P2D` mode, the function is called directly with `options` and drawn to the main context. * @param {Object} params * @param {p5.Graphics} params.graphics - Rendering context. * @param {Object} params.options - Display options (e.g. origin). * @param {Function} params.value - Function that draws into the framebuffer. * @param {number} [params.cellLength=this.cellLength] - Cell size in pixels. */ static functionDisplay({ mode, graphics, options, value, cellLength, _this }?: { graphics: p5.Graphics; options: any; value: Function; cellLength?: number; }): void; /** * Renders an image or framebuffer value. * @param {Object} params * @param {p5.Graphics} params.graphics - Rendering context. * @param {*} params.value - Image, p5.Graphics, or Framebuffer. * @param {number} [params.cellLength=this.cellLength] - Cell size in pixels. */ static imageDisplay({ graphics, value, cellLength }?: { graphics: p5.Graphics; value: any; cellLength?: number; }): void; /** * Renders a boolean value centered in the cell using `stringDisplay`. * Displays βœ… for `true` and ❎ for `false`. * @param {Object} params * @param {p5.Graphics} params.graphics - Rendering context. * @param {boolean} params.value - Boolean value to render. * @param {p5.Font} [params.textFont] - Optional font. * @param {number} [params.cellLength=this.cellLength] - Cell size in pixels. * @param {*} [params.textColor=this.textColor] - Fill color for text. * @param {number} [params.textZoom=this.textZoom] - Text size scaling factor. */ static booleanDisplay({ graphics, value, textFont, cellLength, textColor, textZoom }?: { graphics: p5.Graphics; value: boolean; textFont?: p5.Font; cellLength?: number; textColor?: any; textZoom?: number; }): void; /** * Renders a string value centered in the cell. * @param {Object} params * @param {p5.Graphics} params.graphics - Rendering context. * @param {string} params.value - Text to render. * @param {p5.Font} [params.textFont] - Optional font. * @param {number} [params.cellLength=this.cellLength] - Cell size in pixels. * @param {*} [params.textColor=this.textColor] - Fill color for text. * @param {number} [params.textZoom=this.textZoom] - Text size scaling factor. */ static stringDisplay({ graphics, value, textFont, cellLength, textColor, textZoom }?: { graphics: p5.Graphics; value: string; textFont?: p5.Font; cellLength?: number; textColor?: any; textZoom?: number; }): void; /** * Draws the outline (tile) for a cell. * @param {Object} params * @param {p5.Graphics} params.graphics - Rendering context. * @param {number} [params.cellLength=this.cellLength] - Cell size in pixels. * @param {*} [params.outline=this.outline] - Outline color. * @param {number} [params.outlineWeight=this.outlineWeight] - Stroke weight. */ static tileDisplay({ graphics, cellLength, outline, outlineWeight }?: { graphics: p5.Graphics; cellLength?: number; outline?: any; outlineWeight?: number; }): void; /** * Constructs a new Quadrille instance with multiple supported initialization modes: * 1. No arguments β†’ 8Γ—8 chessboard with default colors. * 2. width, height β†’ empty quadrille of given dimensions. * 3. two colors β†’ 8Γ—8 chessboard with custom light/dark colors. * 4. jagged or flat array β†’ quadrille from array contents. * 5. width + array β†’ array reshaped into rows. * 6. string β†’ single-row from characters. * 7. width + string β†’ reshaped string. * 8. width + image β†’ visual content from image. * 9. width + image + boolean β†’ image pixelation. * 10. width + height + predicate + value β†’ fill by predicate. * 11. width + height + order + value β†’ filled by order (random). * 12. width + bitboard + value [+ littleEndian] β†’ bitboard pattern (auto height). * 13. width + height + bitboard + value [+ littleEndian] β†’ bitboard pattern (explicit size). * Used internally by `p5.prototype.createQuadrille`. * @param {p5} p - The p5 instance. * @param {...any} args - Arguments to select construction mode. */ constructor(p: p5, ...args: any[]); _p: p5; _cellLength: any; _x: number; _y: number; _origin: string; _memory2D: any[][]; /** * Sets quadrille from 2D memory internal array representation. * Accepts either a 2D array, 1D array, FEN string, or flat string. * @param {Array|String} memory - Array or string used to set the internal memory. */ set memory2D(memory: any[] | string); /** * Gets the internal 2D array representation of the quadrille. * @returns {Array>} */ get memory2D(): Array>; _init1D(memory1D: any, width?: any): void; _format(memory1D: any, size: any): any; _fromFEN(...args: any[]): void; _fromImage(...args: any[]): void; _pixelator1(image: any): void; _pixelator2(image: any): void; _images(image: any): void; _fromIndex(index: any, width?: number): { row: number; col: number; }; _toIndex(row: any, col: any, width?: number): any; /** * Returns the bit index of the given cell using the instance’s width and height. * Delegates to the static version. * @param {number} row - Row index of the cell. * @param {number} col - Column index of the cell. * @param {boolean} [littleEndian=false] - Whether to use little-endian ordering. * @returns {number|undefined} The bit index, or undefined if out of bounds. */ bitIndex(row: number, col: number, littleEndian?: boolean): number | undefined; /** * Returns the cell position for a given bit index using the instance’s dimensions. * Delegates to the static version. * @param {number|bigint} bitIndex - Bit index to convert. * @param {boolean} [littleEndian=false] - Whether to use little-endian ordering. * @returns {{row: number, col: number}|undefined} The cell position, or undefined if out of bounds. */ bitCell(bitIndex: number | bigint, littleEndian?: boolean): { row: number; col: number; } | undefined; /** * Iterates over cells and calls the given function with each matching cell object, * in row-major order (row 0..height-1, within each row col 0..width-1). * The optional `filter` determines which cells are visited: * - `null`, `undefined` β†’ all cells * - `Function({ row, col, value })` β†’ cells where the predicate returns `true` * - `Array` / `Set` of values β†’ cells whose value is contained in the collection * - single value (non-function, non-collection) β†’ cells whose value === filter * Note: this function does NOT short-circuit; it always visits all eligible cells. * @param {(cell: { row: number, col: number, value: any }) => any} callback * @param {Array|Set|Function|*|null} [filter] * @returns {void} */ visit(callback: (cell: { row: number; col: number; value: any; }) => any, filter?: any[] | Set | Function | any | null): void; /** * Sets quadrille width (number of columns). * Triggers transposition hack to simulate column resizing. * @param {number} width */ set width(width: number); /** * Gets quadrille width. * @returns {number} Number of columns. */ get width(): number; /** * Sets quadrille height (number of rows). * Resizes by inserting or deleting rows. * @param {number} height */ set height(height: number); /** * Gets quadrille height. * @returns {number} Number of rows. */ get height(): number; /** * Gets total number of cells (width Γ— height). * @returns {number} */ get size(): number; /** * Gets number of filled cells in the quadrille. * @returns {number} */ get order(): number; /** * Gets the row index under the mouse. * @returns {number} */ get mouseRow(): number; /** * Gets the column index under the mouse. * @returns {number} */ get mouseCol(): number; /** * Gets the minimal axis-aligned span of filled cells. * Returns undefined if the quadrille has no filled cells. * @returns {{row:number, col:number, width:number, height:number}|undefined} */ get span(): { row: number; col: number; width: number; height: number; } | undefined; /** * Counts the number of non-empty cells in the specified row. * @param {number} row - Row index. * @returns {number} Number of filled cells in the row. */ magnitude(row: number): number; /** * Searches the quadrille for matches to a given pattern quadrille. * @param {Quadrille} pattern - The pattern to search for. * @param {boolean} [strict=false] - Whether values must match exactly, not just be filled. * @returns {Array<{ row: number, col: number }>} An array of match locations. Empty if no match. */ search(pattern: Quadrille, strict?: boolean): Array<{ row: number; col: number; }>; /** * Converts a pixel Y coordinate to a quadrille row index. * @param {number} pixelY - The screen Y-coordinate in pixels. * @param {number} [y=this._y || 0] - The quadrille's Y-coordinate origin. * @param {number} [cellLength=this._cellLength || this.constructor.cellLength] - Length of each cell. * @returns {number} The row index corresponding to the pixel Y-coordinate. */ screenRow(pixelY: number, y?: number, cellLength?: number): number; /** * Converts a screen X-coordinate to a quadrille column index. * @param {number} pixelX - The screen X-coordinate in pixels. * @param {number} [x=this._x || 0] - The quadrille's X-coordinate origin. * @param {number} [cellLength=this._cellLength || this.constructor.cellLength] - Length of each cell. * @returns {number} - The corresponding quadrille column. */ screenCol(pixelX: number, x?: number, cellLength?: number): number; /** * Reads the value at the specified row and column. * @param {number} row * @param {number} col * @returns {*} Quadrille entry at (row, col), or `undefined` if out of bounds. */ read(row: number, col: number): any; /** * Checks if a given cell position is valid. * @param {number} row * @param {number} col * @returns {boolean} True if the cell is within bounds. */ isValid(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) is empty. * @param {number} row * @param {number} col * @returns {boolean} */ isEmpty(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) is filled. * @param {number} row * @param {number} col * @returns {boolean} */ isFilled(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains a boolean. * @param {number} row * @param {number} col * @returns {boolean} */ isBoolean(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains a symbol. * @param {number} row * @param {number} col * @returns {boolean} */ isSymbol(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains a number. * @param {number} row * @param {number} col * @returns {boolean} */ isNumber(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains a BigInt. * @param {number} row * @param {number} col * @returns {boolean} */ isBigInt(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains a string. * @param {number} row * @param {number} col * @returns {boolean} */ isString(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains a color. * @param {number} row * @param {number} col * @returns {boolean} */ isColor(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains an array. * @param {number} row * @param {number} col * @returns {boolean} */ isArray(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains an object. * @param {number} row * @param {number} col * @returns {boolean} */ isObject(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains an image or graphics object. * @param {number} row * @param {number} col * @returns {boolean} */ isImage(row: number, col: number): boolean; /** * Checks whether the cell at (row, col) contains a function. * @param {number} row * @param {number} col * @returns {boolean} */ isFunction(row: number, col: number): boolean; /** * Replaces cell values. * 1. `replace(value)` β€” replaces all filled cells with `value`. * 2. `replace(value1, value2)` β€” replaces occurrences of `value1` with `value2`. * @param {...*} args * @returns {Quadrille} The modified quadrille (for chaining). */ replace(...args: any[]): Quadrille; /** * Clears cell values in various ways: * 1. `clear()` β€” clears all filled cells. * 2. `clear(predicate)` β€” clears all cells for which the predicate returns true. * 3. `clear(row)` β€” clears a specific row. * 4. `clear(bitboard, littleEndian = false)` β€” clears filled cells based on a bitboard (as a BigInt); MSB corresponds to the top-left cell by default. * 5. `clear(row, col)` β€” clears a specific cell. * 6. `clear(row, col, directions)` β€” flood clears from a cell. * 7. `clear(row, col, border)` β€” flood clears from a cell with optional border clearing. * 8. `clear(row, col, directions, border)` β€” flood clears from a cell using given directions and border. * @param {...*} args * @returns {Quadrille} The modified quadrille (for chaining). */ clear(...args: any[]): Quadrille; /** * Fills the quadrille using a variety of modes: * 1. `fill()` β€” fills all cells in chessboard pattern using default colors. * 2. `fill(value)` β€” fills all empty cells with a value or factory. * 3. `fill(predicate, value)` β€” fills matching cells with a value. * 4. `fill(color1, color2)` β€” fills chessboard with specified colors. * 5. `fill(row, value)` β€” fills a specific row. * 6. `fill(bitboard, value, littleEndian = false)` β€” fills empty cells based on a bitboard. * 7. `fill(row, col, value)` β€” fills a specific cell. * 8. `fill(row, col, value, directions)` β€” flood fill in directions. * 9. `fill(row, col, value, border)` β€” flood fill with/without border. * 10. `fill(row, col, value, directions, border)` β€” full flood fill. * @param {...*} args - Arguments as described above. * @returns {Quadrille} This quadrille (for chaining). */ fill(...args: any[]): Quadrille; /** * Internal helper to evaluate a value for a given cell. * If the value is a function tagged with `._isFactory`, it is called * with `{ row, col }`. Otherwise, the value is returned as-is. * @param {*} value - A literal, display function, or factory function. * @param {number} row - Row index of the cell. * @param {number} col - Column index of the cell. * @returns {*} Evaluated cell content. */ _parseFn(value: any, row: number, col: number): any; /** * Clears a cell value before writing a new one into the grid. * If the value is a function or object and contains an internal * framebuffer (`fbo`), the framebuffer is removed and the reference * is cleared to avoid memory leaks. This is used to manage retained * drawing resources for function-based or object-based displays. * @param {*} value - The current cell value to be cleared. * @returns {null} Always returns null as the cleared cell value. */ _clearCell(value: any): null; /** * Recursive flood fill using value1 β†’ value2 replacement. * Supports 4- or 8-directional movement and optional border fill. * @private */ private _flood; /** * Randomly clears or fills cells in the quadrille. * - If `value` is `null`, clears `times` filled cells. * - If `value` is not `null`, fills `times` empty cells with `value`. * Note: For deterministic behavior, call `randomSeed(seed)` explicitly before this method. * @param {number} times - Number of cells to modify. * @param {*} [value=null] - Value to fill, or `null` to clear cells. * @returns {Quadrille} The modified quadrille (for chaining). */ rand(times: number, value?: any): Quadrille; /** * Randomly rearranges filled cells in the quadrille. * Note: For deterministic behavior, call `randomSeed(seed)` explicitly before this method. * @returns {Quadrille} The modified quadrille (for chaining). */ randomize(): Quadrille; /** * Inserts an empty row at the given index. * @param {number} row - Index to insert the new row. * @returns {Quadrille} The modified quadrille (for chaining). */ insert(row: number): Quadrille; /** * Deletes the row at the given index. * @param {number} row - Index of the row to delete. * @returns {Quadrille} The modified quadrille (for chaining). */ delete(row: number): Quadrille; /** * Swaps two rows or two cells in the quadrille. * - `swap(row1, row2)` β€” swaps two rows. * - `swap(row1, col1, row2, col2)` β€” swaps two individual cells. * @param {...number} args - Either 2 or 4 integers. * @returns {Quadrille} The modified quadrille (for chaining). */ swap(...args: number[]): Quadrille; /** * Shifts all filled cells by (dRow, dCol) across the grid. * - dRow > 0: down; dRow < 0: up * - dCol > 0: right; dCol < 0: left * wrap=true (default): toroidal wrap; wrap=false: clip at edges. * @param {number} dRow * @param {number} dCol * @param {boolean} [wrap=true] * @returns {Quadrille} this */ shift(dRow: number, dCol: number, wrap?: boolean): Quadrille; /** * Inverts filled/empty status in-place. * - Filled cells become empty (cleared). * - Empty cells get filled with `target`. * @param {*} target Value to place into previously-empty cells * @returns {Quadrille} this */ not(target: any): Quadrille; /** * Logical AND between this quadrille and another. * @param {Quadrille} q Second quadrille * @param {number} row Relative row offset from this * @param {number} col Relative column offset from this * @returns {Quadrille} This quadrille containing only cells filled in both */ and(q: Quadrille, row: number, col: number): Quadrille; /** * Logical OR between this quadrille and another. * @param {Quadrille} q Second quadrille * @param {number} row Relative row offset from this * @param {number} col Relative column offset from this * @returns {Quadrille} This quadrille containing cells filled in either */ or(q: Quadrille, row: number, col: number): Quadrille; /** * Logical XOR between this quadrille and another. * @param {Quadrille} q Second quadrille * @param {number} row Relative row offset from this * @param {number} col Relative column offset from this * @returns {Quadrille} This quadrille containing cells filled in one, but not both */ xor(q: Quadrille, row: number, col: number): Quadrille; /** * Logical difference (this minus q) between two quadrilles. * @param {Quadrille} q Second quadrille * @param {number} row Relative row offset from this * @param {number} col Relative column offset from this * @returns {Quadrille} This quadrille with cells filled in this but not in q */ diff(q: Quadrille, row: number, col: number): Quadrille; /** * Merges another quadrille into this one by applying a binary operator. * Uses an in-place fast path when dimensions match and there is no offset. * @param {Quadrille} q * @param {(a: *, b: *) => *} operator * @param {number} [row] * @param {number} [col] * @returns {Quadrille} this */ merge(q: Quadrille, operator: (a: any, b: any) => any, row?: number, col?: number): Quadrille; /** * Horizontal reflection. * Reverses the order of the rows. * @returns {Quadrille} The modified quadrille (for chaining). */ reflect(): Quadrille; /** * Transposes the quadrille matrix (rows become columns). * @returns {Quadrille} The modified quadrille (for chaining). */ transpose(): Quadrille; /** * Rotates the quadrille 90 degrees clockwise. * @returns {Quadrille} The modified quadrille (for chaining). */ rotate(): Quadrille; /** * Returns a bitboard representation of the quadrille. * Only filled cells are considered. * Bits are ordered in **row-major** layout. * By default, the representation is **big-endian**: the top-left cell is the most significant bit. * To use **little-endian** encoding (bottom-right as most significant bit), pass `true`. * @param {boolean} [littleEndian=false] - If true, encodes using little-endian order. * @returns {bigint} Binary representation of the filled pattern. */ toBigInt(littleEndian?: boolean): bigint; /** * Returns a flattened array representation of the quadrille. * @returns {Array<*>} */ toArray(): Array; /** * Saves a rendered image of the quadrille using the specified drawing parameters. * @param {string} filename - The output filename (PNG or JPG). * @param {Object} [params={}] - Rendering parameters. * @param {Array} [params.values] - Optional value set to control rendering. * @param {p5.Font} [params.textFont] - Font used for text rendering. * @param {string} [params.origin='corner'] - Origin mode: `'corner'` or `'center'`. * @param {Object} [params.options={}] - Additional display options. * @param {Function} [params.tileDisplay] - Function to draw tile-based values. * @param {Function} [params.functionDisplay] - Function to draw function-based values. * @param {Function} [params.imageDisplay] - Function to draw image-based values. * @param {Function} [params.colorDisplay] - Function to draw color values. * @param {Function} [params.stringDisplay] - Function to draw string values. * @param {Function} [params.numberDisplay] - Function to draw number values. * @param {Function} [params.bigintDisplay] - Function to draw bigint values. * @param {Function} [params.booleanDisplay] - Function to draw boolean values. * @param {Function} [params.symbolDisplay] - Function to draw symbol values. * @param {Function} [params.arrayDisplay] - Function to draw array values. * @param {Function} [params.objectDisplay] - Function to draw object values. * @param {number} [params.cellLength=this._cellLength] - Cell size in pixels. * @param {number} [params.outlineWeight] - Outline stroke weight. * @param {string|*} [params.outline] - Outline color. * @param {string|*} [params.textColor] - Text fill color. * @param {number} [params.textZoom] - Scale factor for text rendering. */ toImage(filename: string, { filter, textFont, origin, options, tileDisplay, functionDisplay, imageDisplay, colorDisplay, stringDisplay, numberDisplay, bigintDisplay, booleanDisplay, symbolDisplay, arrayDisplay, objectDisplay, cellLength, outlineWeight, outline, textColor, textZoom }?: { values?: any[]; textFont?: p5.Font; origin?: string; options?: any; tileDisplay?: Function; functionDisplay?: Function; imageDisplay?: Function; colorDisplay?: Function; stringDisplay?: Function; numberDisplay?: Function; bigintDisplay?: Function; booleanDisplay?: Function; symbolDisplay?: Function; arrayDisplay?: Function; objectDisplay?: Function; cellLength?: number; outlineWeight?: number; outline?: string | any; textColor?: string | any; textZoom?: number; }): void; /** * Returns a FEN (Forsyth–Edwards Notation) string of the quadrille. * Only works on 8Γ—8 boards. * Symbols not found in the chess map are replaced with '?'. * @returns {string|undefined} */ toFEN(): string | undefined; /** * Returns a shallow copy of this quadrille. * @returns {Quadrille} A new Quadrille with the same content. */ clone(): Quadrille; /** * Crops a rectangular region. Positive/negative width/height control direction. * Optionally wraps indices. * @param {number} row * @param {number} col * @param {number} width * @param {number} height * @param {boolean} [wrap=false] * @returns {Quadrille|undefined} */ crop(row: number, col: number, width: number, height: number, wrap?: boolean): Quadrille | undefined; /** * Returns a new quadrille trimmed to its minimal span of filled cells. * Returns undefined if the quadrille has no filled cells. * @returns {Quadrille|undefined} */ trim(): Quadrille | undefined; /** * Creates a new square quadrille centered at (row, col) with side = 2*dimension+1. * @param {number} row * @param {number} col * @param {number} [dimension=1] Radius of the square (>= 0). * @param {boolean} [wrap=false] When true, indices wrap around grid bounds. * @returns {Quadrille|undefined} */ ring(row: number, col: number, ...args: any[]): Quadrille | undefined; /** * Extracts a single row as a new 1Γ—W Quadrille. * @param {number} row * @returns {Quadrille|undefined} */ row(row: number): Quadrille | undefined; /** * Applies convolution using a quadrille kernel mask. * 1. `filter(mask)` β€” convolves entire quadrille. * 2. `filter(mask, row, col)` β€” convolves only at (row, col). * Kernel weights can be numeric or color-based (luma is used to convert colors). * @param {Quadrille} mask - An odd-sized square kernel quadrille. * @param {number} [row] - Row index to apply convolution. * @param {number} [col] - Column index to apply convolution. * @returns {Quadrille} The modified quadrille (for chaining). */ filter(mask: Quadrille, row?: number, col?: number): Quadrille; _conv(mask: any, row: any, col: any, cache_half_size?: number, source?: this): void; /** * Colorizes a triangle defined by three corners using barycentric interpolation. * @param {number} row0 * @param {number} col0 * @param {number} row1 * @param {number} col1 * @param {number} row2 * @param {number} col2 * @param {*} color0 - Color for vertex 0 (p5.Color, array, or string). * @param {*} [color1=color0] - Color for vertex 1. * @param {*} [color2=color0] - Color for vertex 2. */ colorizeTriangle(row0: number, col0: number, row1: number, col1: number, row2: number, col2: number, color0: any, color1?: any, color2?: any): void; /** * Colorizes the quadrille using four corner colors, interpolated over two triangles. * @param {*} color0 - Upper-left corner color. * @param {*} [color1=color0] - Bottom-left corner color. * @param {*} [color2=color0] - Upper-right corner color. * @param {*} [color3=color0] - Bottom-right corner color. */ colorize(color0: any, color1?: any, color2?: any, color3?: any): void; /** * Rasterizes a triangle using attribute interpolation and a fragment shader function. * @param {number} row0 * @param {number} col0 * @param {number} row1 * @param {number} col1 * @param {number} row2 * @param {number} col2 * @param {Function} shader - Function to apply per-cell, receives interpolated attributes. * @param {Array} array0 - Attribute data for vertex 0. * @param {Array} [array1=array0] - Attribute data for vertex 1. * @param {Array} [array2=array0] - Attribute data for vertex 2. * @returns {Quadrille} The modified quadrille (for chaining). */ rasterizeTriangle(row0: number, col0: number, row1: number, col1: number, row2: number, col2: number, shader: Function, array0: Array, array1?: Array, array2?: Array): Quadrille; /** * Rasterizes the quadrille using four corner attribute arrays and a shader function. * @param {Function} shader - Function to apply per-cell. * @param {Array} array0 - Upper-left corner attributes. * @param {Array} [array1=array0] - Bottom-left corner attributes. * @param {Array} [array2=array0] - Upper-right corner attributes. * @param {Array} [array3=array0] - Bottom-right corner attributes. */ rasterize(shader: Function, array0: Array, array1?: Array, array2?: Array, array3?: Array): void; _barycentric_coords(row: any, col: any, row0: any, col0: any, row1: any, col1: any, row2: any, col2: any): { w0: number; w1: number; w2: number; }; _parallelogram_area(row0: any, col0: any, row1: any, col1: any, row2: any, col2: any): number; _edge_functions(row: any, col: any, row0: any, col0: any, row1: any, col1: any, row2: any, col2: any): { e01: number; e12: number; e20: number; }; /** * Sorts cells by color values. * Sorting `mode` options are: * - `'LUMA'` β€” weighted grayscale value (default). * - `'AVG'` β€” average of red, green, and blue channels. * - `'DISTANCE'` β€” Euclidean distance to a target color in RGBA space. * @param {Object} [params={}] - Sorting parameters. * @param {'LUMA'|'AVG'|'DISTANCE'} [params.mode='LUMA'] - Sorting strategy. * @param {*} [params.target] - Target color (for `'DISTANCE'` mode). * @param {boolean} [params.ascending=true] - Sort order. * @param {string|*} [params.textColor] - Text color. * @param {number} [params.textZoom] - Text scaling factor. * @param {string|*} [params.background] - Background color. * @param {number} [params.cellLength] - Cell size in pixels. * @param {number} [params.outlineWeight] - Stroke weight for cell outlines. * @param {string|*} [params.outline] - Outline color. * @param {p5.Font} [params.textFont] - Optional text font. * @param {string} [params.origin='corner'] - Origin mode. * @param {Object} [params.options={}] - Optional render config. * @param {Function} [params.imageDisplay] * @param {Function} [params.colorDisplay] * @param {Function} [params.stringDisplay] * @param {Function} [params.numberDisplay] * @param {Function} [params.bigintDisplay] * @param {Function} [params.booleanDisplay] * @param {Function} [params.symbolDisplay] * @param {Function} [params.arrayDisplay] * @param {Function} [params.objectDisplay] * @param {Function} [params.functionDisplay] * @param {Function} [params.tileDisplay] * @returns {Quadrille} The sorted quadrille (for chaining). */ sort({ mode, target, ascending, textColor, textZoom, background, cellLength, outlineWeight, outline, textFont, origin, options, imageDisplay, colorDisplay, stringDisplay, numberDisplay, bigintDisplay, booleanDisplay, symbolDisplay, arrayDisplay, objectDisplay, functionDisplay, tileDisplay }?: { mode?: "LUMA" | "AVG" | "DISTANCE"; target?: any; ascending?: boolean; textColor?: string | any; textZoom?: number; background?: string | any; cellLength?: number; outlineWeight?: number; outline?: string | any; textFont?: p5.Font; origin?: string; options?: any; imageDisplay?: Function; colorDisplay?: Function; stringDisplay?: Function; numberDisplay?: Function; bigintDisplay?: Function; booleanDisplay?: Function; symbolDisplay?: Function; arrayDisplay?: Function; objectDisplay?: Function; functionDisplay?: Function; tileDisplay?: Function; }): Quadrille; } import p5 from 'p5';