Quadrille API

Quadrille API

The Quadrille API gives you a compact and flexible toolkit for grid-based programming in p5.js. Whether you’re building games, simulations, or creative visuals, it helps you create, manipulate, and render layers of cell-based data with ease.

This chapter is your entry point into the API. Start by hacking a sketch or trying out a classic like Tic Tac Toe. From there, you can explore the rest of the API at your own pace, guided by live examples and interactive ideas.

The API is organized into sections to help you find what you need:

  • p5 Functions: Create and display quadrilles directly in your p5.js sketch.
  • Iterators: Loop over cells, filter values, or run callbacks on specific patterns.
  • Properties: Check the current state of a quadrille—dimensions, contents, and more.
  • Accessors: Query what’s in a cell, find matches, or convert between screen and grid.
  • Mutators: Modify the grid—fill it, randomize it, clear it, or swap things around.
  • Algebra: Combine quadrilles using logical operations like AND, OR, and XOR.
  • Transforms:Flip, rotate, or transpose your grid like a spreadsheet or matrix.
  • Visual Algorithms: Sort, filter, colorize, or rasterize your data with algorithmic flair.
  • Reformatter: Convert quadrilles into arrays, strings, images, or chess-style notations.

Use the sidebar to jump into any section. If you’re just getting started, begin with p5 Functions and explore the Tic Tac Toe example to get a feel for how everything fits together.