The quadrille algebra provides a suite of static methods for applying logical operations to quadrille instances. Inspired by constructive solid geometry and boolean algebra, these methods combine and manipulate quadrilles, leading to new quadrilles as an aggregation of others.
Method Overview#
- not(q, value): Performs a logical NOT operation, inverting empty and non-empty cells, filling empty cells with a provided
value. - or(q1, q2, row, col): Combines two quadrilles using a logical OR, merging their non-empty cells into a new quadrille.
- xor(q1, q2, row, col): Returns a new quadrille containing all the non-empty cells that appear in either
q1orq2but not in both. - and(q1, q2, row, col): Returns a new quadrille containing only the cells that are non-empty in both
q1andq2. - diff(q1, q2, row, col): Returns a new quadrille containing the non-empty cells from
q1that do not appear inq2. - merge(q1, q2, operator, row, col): Returns a new quadrille by applying a specified logical
operatorto each corresponding cell ofq1andq2.
These algebraic methods offer powerful tools for composing quadrilles, enabling the construction of intricate patterns, designs, or logical transformations. Whether you’re combining shapes, masking cells, or creating dynamic compositions, the quadrille algebra brings structure and precision to your work.
All algebra methods also have destructive, chainable instance forms: they mutate
qand return it.Single-step:
q.not('#000'),q.and(q2),q.diff(mask)
Chained:q.not('#000').or(q2).and(q3),q.or(stamp, 2, -1).diff(mask),q.merge(mask, op, 1, 0).xor(qHole).not('#fff')