The p5.quadrille surface

The library's own names, grouped by teaching area as the API pages are, and ordered by how many examples reach for them. createQuadrille, drawQuadrille and Quadrille.cellLength come first, and the surface a sketch grows into follows; each name links to the page that documents it.

Only a provable call is here: Quadrille.name, the two p5 functions the addon registers, or a member call on a variable the same snippet made with createQuadrille. A name reached through a receiver of unknown type is left out rather than guessed, so a page's list can be incomplete but never wrong.

p5 Functions

SurfaceWhat it isExamples
drawQuadrille Draws the given Quadrille to the canvas or a p5.Graphics context. 115
createQuadrille Creates a new Quadrille instance. 113
cellLength Gets the current cell size in pixels. 100
tileDisplay Draws the outline (tile) for a cell. 9
chessSymbols Gets a copy of the FEN → symbol map. 6
outlineWeight Gets the current outline stroke weight. 6
darkSquare Gets the color for dark chessboard squares. 4
lightSquare Gets the color for light chessboard squares. 4
outline Gets the current outline color. 4
textColor Gets the current text color. 3
thinWall Thin-wall display function — a value-agnostic display passed per draw, never stored: walls stay whatever they are (colors, images, emojis, …), and the thin look is pure draw-site styling. 3
chessKeys Gets a reverse map from symbol to FEN key. 2
textZoom Gets the current text zoom scale. 2
colorDisplay Renders a color value by filling the cell. 1
factory Tags a function as a factory, meaning it should be executed during fill. 1
singleton Declares that a value is a shared singleton to be reused across cells. 1

Iterators

SurfaceWhat it isExamples
visit 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). 11

Properties

SurfaceWhat it isExamples
mouseRow Gets the row index under the mouse. 36
mouseCol Gets the column index under the mouse. 30
width Gets quadrille width. 7
height Gets quadrille height. 4
size Gets total number of cells (width × height). 4
order Gets number of filled cells in the quadrille. 3
span Gets the minimal axis-aligned span of filled cells. 2
memory2D Gets the internal 2D array representation of the quadrille. 1

Accessors

SurfaceWhat it isExamples
clone Returns a shallow copy of this quadrille. 6
isValid Checks if a given cell position is valid. 5
isFilled Determines whether a value is considered filled. 2
reach Returns the seed cell's reach as a number-field quadrille — 0 at the seed, steps-to-reach elsewhere, and empty where out of reach — computed as a breadth-first-search wavefront over any quadrille: filled cells are obstacles, empty cells are passable. 2
read Reads the value at the specified row and column. 2
ring Creates a new square quadrille centered at (row, col) with side = 2dimension+1. 2
crop Crops a rectangular region. 1
magnitude Counts the number of non-empty cells in the specified row. 1
path Returns a shortest path between two cells as an array of { row, col } steps — excluding start, including end (the moves, not the position) — following the search return convention. 1
row Extracts a single row as a new 1×W Quadrille. 1
trim Returns a new quadrille trimmed to its minimal span of filled cells. 1

Mutators

SurfaceWhat it isExamples
rand Randomly clears or fills cells in the quadrille. 27
fill Fills the quadrille using a variety of modes: 1. 21
clear Clears cell values in various ways: 1. 15
randomize Randomly rearranges filled cells in the quadrille. 9
maze Clears the quadrille, then generates a perfect maze at the current dimensions, filling wall cells with value — the maze analogue of the zero-arg fill() chessboard. 5
replace Replaces cell values. 2
swap Swaps two rows or two cells in the quadrille. 2
delete Deletes the row at the given index. 1
insert Inserts an empty row at the given index. 1
shift Returns a shifted copy of the given Quadrille. 1

Algebra

SurfaceWhat it isExamples
or Logical OR between two quadrilles. 3
and Logical AND between two quadrilles. 2
not Logical NOT of a quadrille (non-destructive). 2
diff Logical difference (q1 minus q2) between two quadrilles. 1
merge Merges two quadrilles by applying a binary operator to their overlapping cells. 1
xor Logical XOR between two quadrilles. 1

Transforms

SurfaceWhat it isExamples
reflect Horizontal reflection. 1
rotate Rotates the quadrille 90 degrees clockwise. 1
transpose Transposes the quadrille matrix (rows become columns). 1

Visual Algorithms

SurfaceWhat it isExamples
colorizeTriangle Colorizes a triangle defined by three corners using barycentric interpolation. 2
colorize Colorizes the quadrille using four corner colors, interpolated over two triangles. 1
filter Applies convolution using a quadrille kernel mask. 1
rasterizeTriangle Rasterizes a triangle using attribute interpolation and a fragment shader function. 1