# Transformation Matrix (rotate, translate, scale)

Try this

```rect(0, 0, 55, 55);
translate(30, 20);
rect(0, 0, 55, 55);
translate(14, 14);
rect(0, 0, 55, 55);
```

What happened?

And this:

```translate(width/2, height/2);
rect(-25, -25, 50, 50);
```

Example of transformation + scale + rotation.

```void setup()
{
size(200, 200);
background(255);
noStroke();
rectMode(CENTER);

// draw the original position in gray
fill(192);
rect(0, 0, 40, 40);

// draw a translucent blue rectangle in the new position
fill(0, 0, 255, 128);

pushMatrix();
translate(100, 100);
scale(0.5);
rect(0, 0, 40, 40);
popMatrix();
}```

Now reproduce the plotter drawing on the below (Georg Nees Schotter 1968)!

A possible solution:

```size(380, 800);
background(255);
noFill();
rectMode(CENTER);

int rows = 25;
int cols = 12;
int side = 30;

for(int r = 0; r < rows; r++)
{
for(int c = 0; c < cols; c++)
{
pushMatrix();

float scatteringX = random(-r/2, r/2);
float scatteringY = random(-r/2, r/2);

translate(25 + scatteringX + c*side, 25 + r*side + scatteringY);

float randomness = r*2;

float angle = random(-randomness, randomness);