How Canvas and Puzzle abstractions work together
masterHeadbreaker separates the jigsaw data model from its visual representation:
Puzzle: A headless, pure JavaScript data structure that manages the jigsaw model, including individualPieceobjects, their connections, metadata, and spatial transformations (translation, shuffling, etc.). It can run in any environment, including Node.js.Canvas: A visual representation of aPuzzle. It mirrors many of the commonPuzzlemethods but is responsible for rendering the pieces to a web container.
You can access the underlying Puzzle object from a Canvas instance at any time using the .puzzle accessor.
// create and configure the canvas
const canvas = new headbreaker.Canvas(...);
// now you can access and interact with the puzzle object
const puzzle = canvas.puzzle;