Features of a Quadrille

Features of a Quadrille

Welcome to the Quadrille API, a versatile tool designed for creating and managing layers of data cells for various applications, particularly board games. The comprehensive Quadrille API allows you to represent and manipulate these layers dynamically, enabling intricate designs and logic. Below is an interactive snippet that demonstrates the Quadrille API in action.


Features of Quadrille

  1. Data Storage
    Quadrille cells can store any valid JavaScript value, with empty cells represented as null. If a cell is filled with an undefined value, it is automatically converted to null and treated as empty. The library enforces a key invariant: quadrilles are always square, matrix-like objects where each row has the same number of columns, and empty cells are consistently filled with null values.

  2. Rendering
    By default, the library renders cells filled with colors, numbers, strings, images & videos, p5.Graphics, or even (drawing) functions. These default rendering behaviors can be overridden to suit specific requirements.

  3. Multi-Layer Capability
    Multiple quadrilles can be superimposed to form layers, with each layer representing distinct elements or states. Quadrilles are layered back-to-front based on their drawing order. This feature is particularly useful in games where players or objects need separation.

  4. Quadrille Aggregation
    Quadrilles support aggregation during creation, filling, or through static boolean operators, a powerful feature dubbed Quadrille Algebra. For instance, the Quadrille.or operator is used to combine multiple layers into the aggregate shown above, effectively merging data from different quadrilles.

In the snippet above, you’ll see how layers of quadrilles manage different types of data, such as colors, strings, images, videos, and custom graphical elements. Aggregation further enhances this flexibility, allowing you to seamlessly merge and interact with combined data dynamically. The setup enables toggling visibility, aggregating layers, and validating game states interactively.