Mastering HTML5 Canvas

Revolutionize web visualizations with the power of HTML5 canvas
4.8 (7 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
134 students enrolled
$19
$95
80% off
Take This Course
  • Lectures 26
  • Length 3.5 hours
  • Skill Level Expert Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 1/2016 English

Course Description

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.

About The Author

Ben Fhala discovered his passion for data visualization while he was working at Parsons in New York, in their data visualization department, PIIM. He is the owner of the online video training school and an Adobe ACP. He enjoys spending most of his time learning and teaching, and has a love for visual programming and visualization in general. Ben has had the honor of developing applications for members of the US Congress, Prime Ministers, and Presidents around the world.

He has built many interactive experiences for companies such as Target, AT&T, Crayola, Marriott, Neutrogena, and Nokia. He has technically directed many award-winning projects and has been part of teams that have won three Agency of the Year awards.

Among Ben's publications are HTML5 Graphing and Data Visualization Cookbook, and five video courses: jQuery UI Development; Learning Object-Oriented JavaScript; Mastering JavaScript; JavaScript Design Patterns; Web Visualization with HTML5, CSS3, and JavaScript, all for Packt Publishing.

What are the requirements?

  • The video course does not assume any previous know how in graphic design or HTML5 Canvas.

What am I going to get from this course?

  • Familiarize yourself with the foundations of working with the canvas 2D API
  • Control and regulate shapes with the help of quadratic and bezier curves
  • Explore interesting canvas methods to create paths, arcs, shapes, text, and images
  • Work with the beginPath and closePath methods to create your own geometric shapes
  • Use math-based interactions, such as sine and cosine, to build complex shapes and animations with ease
  • Get creative using the canvas features that control curves, colors, images, and gradients
  • Fetch pixel data and manipulate it on the bitmap level with the canvas API
  • Enhance the look and feel of your text using transformation effects such as scale, translate, and rotate

What is the target audience?

  • If you are a JavaScript developer with a solid understanding of the fundamentals of the language and wish to expand your capabilities by learning how to draw and manipulate data through the HTML5 canvas 2D API, this course is for you!

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Getting Started with HTML5 Canvas
02:26

This video will offer an overview of the course.

09:34

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.

06:19

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.

05:03

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.

06:12

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.

Section 2: Creating Shapes Using Paths
09:43

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.

05:29

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.

07:57

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.

12:20

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.

08:46

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.

Section 3: Drawing with Angles
11:31

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.

09:46

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.

10:26

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.

11:48

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.

07:22

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.

Section 4: From Curves to Gradients
07:00

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.

07:23

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.

04:31

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.

07:10

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.

09:06

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.

06:07

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.

Section 5: Manipulating the Canvas
08:17

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.

07:22

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.

09:16

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.

05:53

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.

06:29

To wrap up this course, we are going to cover the three final and major methods that manipulate the full Canvas.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Packt Publishing, Tech Knowledge in Motion

Over the past ten years Packt Publishing has developed an extensive catalogue of over 2000 books, e-books and video courses aimed at keeping IT professionals ahead of the technology curve. From new takes on established technologies through to the latest guides on emerging platforms, topics and trends – Packt's focus has always been on giving our customers the working knowledge they need to get the job done. Our Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.

Ready to start learning?
Take This Course