From the course: Learning HTML Canvas

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Paths

Paths

From the course: Learning HTML Canvas

Start my 1-month free trial

Paths

- [Instructor] So now that we've seen how to draw arch's we'll turn our attention to creating more general paths. As I said earlier, a path consists of a series of connected points. To draw a path you start with the begin path function and then perform some drawing operations. Path's can be opened or closed, and in this case we'll start with an open path. So lets open up the paths_start file and I've already setup some drawing properties for this canvas. So, lets add some code to draw our first path. So, I'll write ctx.beginPath, which is how we open the path. Then I'm going to perform some drawing operations, so I'll move the pen. And I'll move the pen to a point on the canvas and then I'll just draw some lines. So I'll use lineTo to do that. And I'll draw my first line. And then I'll just copy that and draw my second line. Then we'll draw one more line. Then I'll call stroke. That will actually draw the line itself. So, let's go ahead and save and let's just look at what we have in…

Contents