createQuadrille(width, height, predicate, value)
Creates a quadrille of the specified size and fills each cell only if the given predicate({ row, col }) returns true. The filled cells are assigned the provided value.
This method is ideal for generating patterns like diagonals, borders, checkerboards, or any logical layout based on cell position.
Example
(fill the two diagonals with 🌀 symbols)
Syntax
createQuadrille(width, height, predicate, value)
Parameters
| Param | Description |
|---|---|
width |
Number: total number of columns in the quadrille |
height |
Number: total number of rows in the quadrille |
predicate |
Function: receives { row, col } and returns true if the cell should be filled |
value1 |
Any: the value to assign to matching cells. Can be a literal, function, or object |
What this page's examples use
- p5.quadrille
drawQuadrillecreateQuadrillecellLength- p5.js
createCanvasbackground
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.