Tut­o­r­i­a­l­8­_ Dra­w­i­n­g Tra­n­s­f­o­r­m­a­t­i­o­n­s

by Lisa Deng
  • Show Code
/** @peep sketch */
void setup() {
  size(200, 200);
  background(204);
  translate(width/2, height/2);
  scale(1.0/3.0);
  for (int i = 0; i < 30; i++) {
    grid();
    rotate(radians(360.0/30));
    scale(0.9)
  }
}
 
void grid() {
  stroke(0, 32);
  fill(255, 64);
  rect(0, 0, width, height);
  for (int x = 0; x <= width; x += 10) { line(x, 0, x, height); }
  for (int y = 0; y <= height; y += 10) { line(0, y, width, y); }
  stroke(255, 0, 0, 128);
  line(10, 10, 30, 10);
  line(25, 15, 30, 10);
  line(25, 5, 30, 10);
  stroke(0, 0, 255, 128);
  line(10, 10, 10, 30);
  line(15, 25, 10, 30);
  line( 5, 25, 10, 30);
}

Comments