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.

Custom transformations

Custom transformations

From the course: Learning HTML Canvas

Start my 1-month free trial

Custom transformations

- [Narrator] The last transform type we're going to take a look at is the custom transform. In addition to the transforms that are built into the canvas such as scale and translate, you can also define your own. These custom transforms are defined as a matrix of values and it has the format that you see here. This transform matrix is then applied to drawing operations on the canvas. Now, you don't need to panic here. I'm not going to make you learn matrix math, but this feature does come in handy when you want to apply a transformation that is not built into the canvas. So, we'll some examples of how to do that in a moment, but the way that you apply a custom transform is by using one of the two transform functions. The first one is simply called transform and it takes these six arguments which correspond to the variables you see in the matrix. The transform function takes the transform you're defining and adds it to whatever the transform of the canvas currently is because, remember,…

Contents