From the course: Coding for Visual Learners: Learning JavaScript from Scratch

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Rotate and translate

Rotate and translate

- [Instructor] At this point, we are almost ready to work on our final project an interactive game built using JavaScript and p5.js. Before we do that though, I would like to demonstrate a couple of more useful p5.js functions to extend the realm of things that we can build. Notice how we can draw shapes on the screen using our current knowledge but we can't really transform them like rotating them around their center. That's a big blocker on the kind of things that we can be building in p5.js. So let's learn how to do transformations in p5.js to enhance our abilities. Having used other kinds of driving libraries, I should say that doing automats in p5.js such as scaling, rotating, or translating can be a bit unintuitive. Let's start off by looking at p5.js rotate function. So here I will be creating a small example scripts. It'll make the canvas size a little bit bigger. I will call rectMode function with sensor…

Contents