# 2d Transformations

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); rotate(radians(45)); scale(0.5); rect(0, 0, 40, 40); popMatrix(); }```
```  void setup() { size(380, 800); background(255); smooth(); noLoop(); noFill(); }   int rows = 25; int columns = 12; int side = 30; //of the square & distance   //variables to calibrate the randomness float translationRandomness = .5; float rotationRandomness = 1;   void draw() { for (int r = 0; r<rows ; r++) { for (int c = 0; c<columns; c++) { pushMatrix();   //10 is the margin float xPos = 10 + c*side + (random(-translationRandomness*r, translationRandomness*r)); float yPos = 10 + r*side + (random(-translationRandomness*r, translationRandomness*r)); translate(xPos, yPos);   float rotation = random(-r*rotationRandomness, r*rotationRandomness); rotate(radians(rotation));   rect(0, 0, side, side); popMatrix(); } } }```