Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Changing the screen coordinates is an alternative technique to create motion. For instance, you can move a shape 50 pixels to the right, or you can move the location of coordinate (0,0) 50 pixels to the right—the visual result on screen is the same. By modifying the default coordinate system, we can create different transformations including translation, rotation, and scaling. Figure 7-3 demonstrates this graphically.
Working with transformations can be tricky, but the translate() function is the most straightforward, so we'll start with it. This function can shift the coordinate system left, right, up, and down with its two parameters.