Canvas 2D: Command Playground

Write your own ctx.* commands, run them line by line on a real canvas, and see the state the context holds: brush colours, transform, the path not painted…

Why it matters

Canvas powers charts, games, image editors and visualisations. Two beginner puzzles, "why is everything one colour" and "why can I not move my shape", go away once you see the context as a state machine painting pixels, line by line.

The key idea

The context is a state machine, and drawing turns straight into pixels

Common mistakes

Try it in this playground