How VideoPuzzle works: assembling images from live video
Classic jigsaw puzzles are getting boring. A static image you scan in seconds and then play from memory. What if the image was moving? That's exactly the question that started VideoPuzzle.
Why video?
Solving puzzles activates your visual cortex — you hunt for patterns, edges, colors. With a static image, your brain memorizes the layout in a few seconds and play becomes mechanical. A moving video rewrites this process. Every piece is unpredictable: the puppy blinks, the panda raises a paw, steam rises from the cup. Your brain has to adapt in real time.
The result? A game that holds you longer even at the easiest difficulty, because you simply can't predict what a piece will look like a second from now.
Behind the scenes: canvas and Bezier curves
The implementation wasn't trivial. Classic puzzle pieces have characteristic rounded tabs and blanks. To make every piece look like a real jigsaw piece and have neighbors interlock, we generate the shape dynamically:
- Edge generation: For each interior grid edge, we randomly choose a tab orientation. If one piece has a tab sticking right, the neighbor has a blank with the matching shape — interlocking works mathematically.
- Path2D + Bezier: Each piece shape is built from straight lines (flat outer edges) and cubic Bezier curves (rounded tab/blank). Five curves per knob give the shape of a real button with a narrow neck and wider head.
- Clip + drawImage: For each piece we apply
ctx.clip()on its path, then draw the entire video shifted so the piece's original cell aligns with its current position. All this 60 times per second for up to 100 pieces.
Drag & drop and scattered pieces
To make the game feel like a real jigsaw, pieces are scattered around the assembly area. A best-fit algorithm tries 80 positions per piece and picks the one with the largest distance from others. When you drop a piece within 32% of a cell from its correct position, it auto-snaps and locks in.
What's next?
We're planning more videos (now 11), more difficulties (up to 12×12), and maybe a co-op mode where multiple players assemble the same puzzle online. But that's future music — for now you can play the current version.