Canvas Lab
Learn HTML Canvas from scratch. From understanding the fundamentals to building a particle system.
Every lesson has interactive code editors; you can modify examples and see results instantly in your browser. You can draw shapes, animate objects, handle mouse input, and build a particle system from scratch.
Prerequisites: JavaScript (variables, functions, loops, arrays).
Estimated time: Learning is easy, good things take time. On rough estimates, each lesson takes 15 to 30 minutes.
- 00FoundationWhat Canvas is, how it works, the coordinate system, and the ctx objectgetContext, coordinate system, immediate mode
- 01BasicsDrawing rectangles, setting colors, and understanding draw orderfillRect, strokeRect, clearRect, fillStyle
- 02Paths & ShapesCustom shapes with paths, lines, arcs, curvesbeginPath, moveTo, lineTo, arc, bezierCurveTo
- 03Colors & StylesFills, strokes, gradients, transparencyfillStyle, strokeStyle, createLinearGradient, globalAlpha
- 04Text & ImagesRendering text and drawing images on canvasfillText, strokeText, font, drawImage
- 05TransformsTranslate, rotate, scale, and the state stacktranslate, rotate, scale, save, restore
- 06AnimationGame loops, requestAnimationFrame, smooth motionrequestAnimationFrame, clearRect, deltaTime
- 07InteractionMouse and touch input, coordinate mapping, hit detectionmousemove, click, getBoundingClientRect
- 08Particle SystemCapstone project combining everythingAll of the above
- 09Final Boss: The DriftRebuild the macOS Drift screensaver from scratch with a real fluid simulationStable Fluids, advection, projection, bilinear sampling
- AAppendix: The Math Behind CurvesLerps, Bezier equations, Bernstein polynomials, and why every curve is just nested interpolationlerp, quadratic bezier, cubic bezier, De Casteljau