fill(row, col, value, directions, border)

Fills a specific cell and all connected cells holding the same value as it with value, spreading in 4 or 8 directions via flood fill; with border = true, the rim where the flood stops is filled too. The full form of the flood-fill family.

Example

(click on any cell to perform flood fill based on selected options; press any key to reset)

edit, then run

Note

Connected means same value, and sameness is identity (===) — see fill(row, col, value, directions) and fill(row, col, value, border) for the identity and rim notes.

Syntax

fill(row, col, value, directions, border)

Parameters

Param Description
row Number: row index of the cell to start filling [0..height]
col Number: column index of the cell to start filling [0..width]
value1 Any: A valid JavaScript value
directions Number: Number of directions for flood fill (4 or 8), default is 4
border Boolean: Specifies whether to include the border of the flood fill area. Default is false
  1. A plain function value is stored, not called — it becomes a per-cell display routine ({ row, col, options }) => { ... } (see options). To have a function evaluated per cell at fill time — a fresh object or a varied tile per cell — tag it: Quadrille.factory(({ row, col }) => new Object(...)). ↩
What this page's examples use
p5.quadrille
drawQuadrille createQuadrille cellLength mouseRow mouseCol rand fill
p5.js
createCanvas background color value createSelect option selected

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.