Quadrille.factory
Tags a function so that fill runs it once per cell and stores what it returns, instead of storing the function itself as that cell's display routine.
A function value in a quadrille is normally a display function: it is called at draw time with the cell's drawing parameters. A function that produces a value has no way to say so, and no amount of introspection can tell the two apart β so the tag is explicit. Quadrille.factory(fn) marks the function in place (fn._isFactory = true) and returns it; a non-function comes back unchanged.
Example
Note
The factory receives
{ row, col }β enough to make a fresh object, a varied tile, or a value that depends on position. The same tag makes thevalueargument ofcreateQuadrilleandfillproduce per-cell values; seecreateQuadrille(width, height, predicate, value)for the predicate form, which decides which cells are filled rather than what they hold.
What this page's examples use
- p5.quadrille
drawQuadrillecreateQuadrillecellLengthfillfactory- 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.