Take this

Software Development / Web Development

Mastering HTML5 Canvas

Revolutionize web visualizations with the power of HTML5 canvas


Web development is an exciting, ever-changing world that is getting progressively dynamic. What web developers need in this fast-paced world is the power of controlling visualizations on the fly—and in comes HTML5 canvas to the rescue! Powered by JavaScript, this powerful 2D API helps developers create graphics and animations directly in the browser. It offers great portability and works on almost all modern browsers, making it accessible just about anywhere.

Mastering HTML5 Canvas walks you through the fascinating arena of web development, covering all the critical concepts of drawing and manipulating pixels in the canvas through tons of examples and designs.

We start the course off by introducing the foundations of the canvas API. You’ll learn how to create canvas elements dynamically and draw basic shapes, and you’ll get familiar with the work environment. Then we shift our focus on to drawing, where you will draw lines, original shapes, paths, and even multiple pointed shapes.

Next, we’ll then leverage the logic that stands behind the cosine and sine functions and through them, create more complicated shapes. This new insight will enable you to create more complex and advanced shape combinations. We will continue our journey by getting to grips with the various types of curves, images, and gradient colors. Finally, we will deal with manipulation of the canvas itself.

By the end of this course, you will know how to draw in HTML5 canvas, create complex shapes, and use angles, arcs, and curves to create your own art work. You will be a master of the HTML5 2D canvas API.

Full details


  • Getting Started with HTML5 Canvas
    The Course Overview
    This video will offer an overview of the course.
    Preparing Our JavaScript for Canvas
    Although most modern browsers support Canvas, not all of them do so. While we won't create an optimal experience for users without the HTML5 Canvas support, we want to create a graceful fallback experience. So, before we start our journey into Canvas, we will prepare our source files to accommodate failures. • Learn the basics of browser compatibility tests • Create a Canvas fallback • Work with ternary operators
    Canvas Hello World
    We start our canvas journey by creating a simple rectangle in the process. We will learn how to define the Canvas size, a fill style, and how to fill it up using the fillRect method. • Let's create our first Canvas drawing • Next, we'll create a rectangle • Then, we'll define a style using fillStyle
    The Palau Flag and the Perfect Circle
    In this video, we will continue working with the flag creation we started in the last video. By the end of this video, we will have created the complete flag of Palau along with a perfect arc—more commonly known as a circle. • We'll work with the arc method • Then, let's create a perfect circle • Finally, we'll create the Palau Flag
    Creating Canvas Elements Dynamically
    Up until now, we worked with the Canvas element that we added onto the stage manually. We will now learn how to dynamically add new Canvas elements into our HTML. • Add multiple types of Canvas onto our page • Create a Canvas generator • Work with the DOM to create new Canvas elements
  • Creating Shapes Using Paths
    Drawing Our First Canvas Lines
    We learned as we created the flag for Palau that when we create a circle using the arc method, we have to trigger a request separately to fill the shape. This is true for all shapes that we create from scratch, and it is true for the creation of lines as well. In this video, we shift our attention to lines. • We'll move our mouse pointer with the moveTo method • Draw a line with the lineTo method • Here, you'll see the difference between fill and stroke
    Meeting Canvas Paths
    In the previous video we, started to create the flag of Greece. We are still short on a few lines of code to complete this flag, but before we can complete creating the flag, we'll encounter another new concept—paths. By the end of this video, you will understand how to work with paths in HTML5 Canvas. • Move from standalone lines to paths • Explicitly define the start point of a shape • Draw the flag of Greece
    Drawing Triangles with Paths
    In this video, we will take advantage of the new method we were introduced to in the previous video, beginPath, to define a path. Only this time, we will define this path as a closed path. By the end of this video, you will know how to work with the beginPath and closePath methods and create your own geometric shapes. • Work with the beginPath and closePath methods • Create a utility function • Draw a triangle in Canvas
    Creating the Flag of Guyana
    In this video, we will take advantage of the new utility function that we created in the previous video to create the flag of Guyana. In the process, we will learn how to create relative designs that can easily scale. • Create relative resizable designs • Utilize our new fillTriangle function • Create the flag of Guyana
    Creating Multipoint Shapes
    In this video, we continue down the road while creating a multishaped object. By the end of this video, you will have a deep understanding of how to work with paths to create complex shapes. • Create multipoint shapes • Use loops to create patterns • Create the flag of Bahrain
  • Drawing with Angles
    Working with Sine, Cosine, and Radians
    As you start to develop more complex shapes, you will need to take advantage of the sine and cosine functions to create complex shapes and animations. In this video, we will revisit the basics of working with sine and cosine as we get ready to build an analog clock flag. • Work with the sine and cosine functions • Find points in a circle • Understand radians
    Creating an Animated Clock
    Now that we know the basics of working with Math.sin and Math.cos, it's time for us to continue and develop a clicking analog clock. • Animate the Canvas elements • Create an updating clock • Work with radians
    Creating Complex Shapes
    It's time to take everything we learned and integrate it into the most complex shape we have seen so far, the Star of David. This star is part of the flag of Israel, and to create it, we will need to use our triangle, sine, and the cosine logic. • Create complex shapes with circles • Layer shapes on top of each other • Watch sine and cosine in action
    Adding More Vertices
    There are many flags that contain stars that just cannot be created by overlapping triangles. In this video, we will figure out how to create a star that contains an arbitrary number of points. We will create the flag of Somalia, and in the process, we'll figure out how to create a function that will enable us to create stars. • Create a multipoint shape • It's all about stars now • Use two virtual circles to create a shape
    Overlapping Shapes to Create Other Shapes
    There are many flags and shapes, in general that can be created by combining the shapes we've created so far. One of the most popular shapes in 82 flags that we don't know how to create is the crescent shape, similar to the one in the flag of Turkey. With it, we learn a new skill that uses subtraction to create more in-depth shapes. • Practice the methods you've learned so far and make yourself perfect • In this step, we'll work with arcs • Overlap shapes to create more complex shapes
  • From Curves to Gradients
    Drawing Arcs
    There are three types of curves that we can create in Canvas—using the arc, quadratic curves, and Bezier curves. In this video, we will shift our attention to the arc again, and, this time, we'll really master its full capabilities. At the end of this video, we will create a pacman and a pie chart example. • Create a pie chart • Create a pacman • Work with arcs
    Drawing with Quadratic Curves
    A quadratic curve is one that has a control point. Consider the case when creating a line; we draw it between two points. When we want to create a quadratic curve, we use an external gravity controller that defines the direction of the curve, while the middle line (the dotted line) defines how far the curve will reach. Let’s learn about this. • Add a control point to create curves • Then, understand how to use the control point • Finally, draw an eye
    Drawing with Bezier Curves
    A bezier curve is one that has two control points. When we want to create a bezier curve, we use two external gravity controllers that define the direction of the curve while one control is on one side and the other is on the other side of the bounded area. • Here, you will be made to understand what are bezier curves • Then, you'll understand how to use the two control point • Next, you'll draw a shape using bezier curves
    Drawing Images into Canvas
    Let's turn our attention to Haiti and get their flag up and running. To create this flag, we need to have the image of the symbol that is placed in the center of the flag. In this video, we will learn how to add images into Canvas, resize them, and how to maintain their original ratio. • First, add images into Canvas • Then, resize images in Canvas • Next, maintain the image ratio when resizing
    Creating an Interactive Linear Gradient
    Since we started our course, all the colors we used were solid colors. It's time for us to take a look at gradients. By the end of this video, you will know how to work with linear gradients. • You will first learn how to create gradients • You will then understand the control points • Finally, you'll learn how to add colors to a gradient
    Working with Interactive Radial Gradient
    In this video, we will explore a more complex type of gradient—a radial gradient. You will learn how to create with it, understand how to control the two anchor points, and the radius of the gradient. • Define two center points • Create two circles to form a sphere • Control and manipulate these shapes
  • Manipulating the Canvas
    Working with Text
    Although the main usage of Canvas is to draw, at times, you might need to add text to canvas. To do this, we will take advantage of a few build int methods and properties of the canvas 2D API. • Add text to Canvas • Grasp the text capabilities of canvas • Work around a text box
    Pixel Manipulation
    Canvas items, when rendered, are represented as bitmap data, and as such, the Canvas API comes with a way for us to manipulate data on the bitmap level. By the end of this video, you will know how to fetch the pixel data and manipulate it. • Manipulate Canvas data pixel by pixel • Invert an image
    The Art of Clipping
    Like any modern drawing editor, the canvas API, too, provides a means to create masking in Canvas. Masking is done using the clip method. In this video, we will learn how to work with the clip method. • Create a grid • Use the rect method • Learn to clip and to restore
    Transforming the Canvas
    Throughout this course, all our manipulations have been targeted at the items that were drawn. In the previous video, we moved to a type of transformation that focused on the Canvas itself, and in the next two videos, we will continue down this path. In this video, we will learn how to transform the Canvas. • First, understand what transformation is • Go over the properties that govern the transformation • Learn about transformations through samples
    Scale, Rotate, and Translate
    To wrap up this course, we are going to cover the three final and major methods that manipulate the full Canvas. • Learn how to scale elements • Learn how to rotate elements • Learn how to translate elements


  • Canvas
  • HTML5
  • JavaScript

Similar Courses

More Courses by this Instructor