Lesson 1, Topic 1
In Progress

Scaling

yousef 13/10/2024

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.