Lesson 4, Topic 3
In Progress

Scaling

John 23/11/2024
Lesson Progress
0% Complete

The final coordinate system transformation is scaling, which changes the size of the grid. Take a look at this program, which draws a square, then scales the grid to twice its normal size, and draws it again.

background(255, 255, 255);
  
stroke(120, 120, 120);
rect(20, 20, 40, 40);
  
pushMatrix();
scale(2.0);
stroke(0, 0, 0);
rect(20, 20, 40, 40);
popMatrix();

First, you can see that the square appears to have moved. It hasn’t, of course. Its upper left corner is still at (20, 20) on the scaled-up grid, but that point is now twice as far away from the origin as it was in the original coordinate system.

Social Community We would like to show you notifications for the latest news and updates.
Dismiss
Allow Notifications