diff(q1, q2, row, col)

Returns a new quadrille with all the filled cells from the q1 quadrille but not from the q2 quadrille.

Example

(to move q2 drag mouse or press a, s, w, z keys)

edit, then run

Note

Observe that the dimensions of the resulting q3 quadrille span the minimum area required to cover both q1 and q2. See merge.

Note

This demo omits row/col on purpose. When they're omitted, the offset is inferred from where each operand was last drawn — the same per-draw capture behind mouseRow/mouseCol: row = row2 − row1, col = col2 − col1 from the operands' last drawQuadrille cell positions (both operands drawn, at cell-aligned positions; otherwise the offset falls back to 0). That's why dragging q2 moves the overlap: each draw refreshes its captured position, and the algebra follows.

Syntax

Quadrille.diff(q1, q2, [row], [col])

Parameters

Param Description
q1 Quadrille: first quadrille to merge
q2 Quadrille: second quadrille to merge
row Number: The vertical displacement of q2 relative to q11. Negative values are allowed
col Number: The horizontal displacement of q2 relative to q12. Negative values are allowed
  1. Default is row2 - row1 if both q1 and q2 are drawn, or 0 otherwise. ↩
  2. Default is col2 - col1 if both q1 and q2 are drawn, or 0 otherwise. ↩
What this page's examples use
p5.quadrille
drawQuadrille createQuadrille cellLength mouseRow mouseCol diff
p5.js
createCanvas color text key

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.