display functions
Display functions determine how quadrille cells are visually rendered based on their values. To disable a specific display function, assign it a value of 0 or null.
| Display Function | Value Type | Default |
|---|---|---|
tileDisplay |
All cells | Quadrille.tileDisplay: Draws cell contours as square tiles |
booleanDisplay |
Boolean | Quadrille.booleanDisplay: Displays ✓ or ✗ depending on the boolean value |
numberDisplay |
Number | Quadrille.numberDisplay: Renders numbers in cells as grayscale colors, clamped to the range [0..255] |
bigintDisplay |
BigInt | Quadrille.bigintDisplay: Displays BigInt values using numberDisplay |
stringDisplay |
String | Quadrille.stringDisplay: Displays strings in cells |
colorDisplay |
Color | Quadrille.colorDisplay: Fills cells with specified p5.Colors |
imageDisplay |
Image | Quadrille.imageDisplay: Draws images in cells |
functionDisplay |
Function | Quadrille.functionDisplay: Executes a function to draw the cell, in both P2D and WEBGL (via a framebuffer in WEBGL) |
arrayDisplay |
Array | No static default. It must be explicitly defined if used |
objectDisplay |
Object | No static default. It must be explicitly defined if used |
symbolDisplay |
Symbol | No static default. It must be explicitly defined if used |
Note
Display function parameters The display functions receive an object with the following properties:
{quadrille, cellLength, outline, outlineWeight, textColor, textZoom, textFont, graphics, origin,value,row,col,width,height, options}. Here,valuecontains the cell content;rowandcolindicate the cell’s position;widthandheightrefer toquadrille.widthandquadrille.height. The options object supports custom parameters and is passed as the sole argument to functions infunctionDisplay. By default, it includesorigin(CORNERinP2D,CENTERinWEBGL) and the cell’srowandcolcoordinates.
Note
Object fallback rendering When no
objectDisplayis specified,drawQuadrille()attempts to render objects using theirdisplayfield, if defined. Ifdisplayis a string, number, color, or image, the corresponding built-in renderer is used. If it is a function, it is called with the options object only, and withthisbound to the object itself — so a one-linedisplay()method can re-enter the API on its own value, e.g. a stored quadrille drawing itself viadrawQuadrille(this, { cellLength }): the pattern behind quadrille-of-quadrilles nesting. Arrays are excluded from this mechanism and must be handled explicitly usingarrayDisplay.
Note
Shipped display function values Beyond the per-type defaults above, the library ships Quadrille.thinWall — a value-agnostic display for the thin-wall maze look, installed per draw as any (or all) of the display params together with
tileDisplay: null.
Example
Note
This example overrides the default square tiling by supplying JavaScript arrow functions to
tileDisplayandcolorDisplay, causing each quadrille cell to render as a circle.
Syntax
drawQuadrille(quadrille, {tileDisplay, numberDisplay, stringDisplay, colorDisplay, imageDisplay, functionDisplay, arrayDisplay, objectDisplay})
Parameters
| Param | Description |
|---|---|
tileDisplay1 |
Function: Renders cell contours. Default is Quadrille.tileDisplay |
booleanDisplay |
Function: Renders boolean values in cells as ✓ or ✗. Default is Quadrille.booleanDisplay |
numberDisplay |
Function: Renders numbers in cells. Default is Quadrille.numberDisplay |
bigintDisplay |
Function: Renders BigInt values using numberDisplay. Default is Quadrille.bigintDisplay |
stringDisplay |
Function: Renders strings in cells. Default is Quadrille.stringDisplay |
colorDisplay |
Function: Renders colors in cells. Default is Quadrille.colorDisplay |
imageDisplay |
Function: Renders images in cells. Default is Quadrille.imageDisplay |
functionDisplay |
Function: Renders functions in cells, in both P2D and WEBGL (via a framebuffer in WEBGL). Default is Quadrille.functionDisplay |
arrayDisplay |
Function: Renders cells filled with arrays. No static default provided |
objectDisplay |
Function: Renders cells filled with objects. No static default provided |
symbolDisplay |
Function: Renders cells filled with symbols. No static default provided |
- The
tileDisplayfunction enables the implementation of regular tilings other than the default square tiling. ↩
What this page's examples use
- p5.quadrille
drawQuadrillecreateQuadrillecellLengthtileDisplaycolorDisplay- p5.js
createCanvasbackgroundcolorfillcreateCheckboxcheckednoStrokecirclenoFillstrokestrokeWeightCORNERellipseMode
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.