Chapter 2. Shape Drawing and Composites

In this chapter, we will cover:

  • Drawing a rectangle
  • Drawing a circle
  • Working with custom shapes and fill styles
  • Fun with Bezier curves: drawing a cloud
  • Drawing transparent shapes
  • Working with the context state stack to save and restore styles
  • Working with composite operations
  • Creating patterns with loops: drawing a gear
  • Randomizing shape properties: drawing a field of flowers
  • Creating custom shape functions: playing card suits
  • Putting it all together: drawing a jet

Introduction

In Chapter 1, Getting Started with Paths and Text, we learned how to draw sub paths such as lines, arcs, Quadratic curves, and Bezier curves, and then we learned how to connect them together to form paths. In this chapter, we'll focus on basic ...

Get HTML5 Canvas Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.