Canvas 2D: draw and animate shapes in the browser

9 steps · about 4 h 20 min · Beginner

  1. Canvas tutorial (guide, MDN Web Docs, 10 min)

    It's the official starting point. It covers what canvas is, the default 300×150 size, and the 2D context object you'll use in every later step.

  2. Drawing shapes with canvas (tutorial, MDN Web Docs, 40 min)

    Rectangles come first, then paths built with beginPath, moveTo, lineTo and stroke. Together they are the base for every shape you draw.

  3. Applying styles and colors (tutorial, MDN Web Docs, 35 min)

    Fill and stroke styles, transparency and gradients make your shapes look finished before you start moving them.

  4. CanvasRenderingContext2D - Web APIs (reference, MDN Web Docs, 15 min)

    Skim the full list of context methods now so you know what exists and can look things up as you build.

  5. Canvas API JavaScript Tutorial: Build Game Graphics From Scratch (2026) (tutorial, Generalist Programmer, 45 min)

    A hands-on pass that ties the coordinate system, shapes, a requestAnimationFrame loop and a bouncing-ball mini-game into one project.

  6. Making a game in Javascript (pt. 1) - Using requestAnimationFrame with Canvas (video, YouTube, 20 min)

    Watching someone code the draw loop live, with input handling, helps the loop pattern click.

  7. Advanced animations (tutorial, MDN Web Docs, 35 min)

    Builds a ball object with position and velocity, then adds wall bounces, trails and mouse control. This is the core pattern for animating shapes.

  8. HTML5 Canvas Animation Tutorial with JavaScript Examples (tutorial, Spicy Yoghurt, 30 min)

    It covers delta time, measuring fps and sharp rendering on high-DPI screens, which stop your animation from looking blurry or running at different speeds.

  9. JavaScript Game Loop with Delta Time and Fixed Timestep (tutorial, Spicy Yoghurt, 30 min)

    The last step is a fixed-timestep loop with start, pause and stop. It's the structure to reuse in your own animations and games.