If(){design}else{art} Processing, le livre

10 mai 2017

Créer un kaléidoscope

Filed under: tips — jean-noël Lafargue @ 12 h 32 min

La fonction qui suit répète une image quatre fois sur l’écran, avec un effet d’inversion qui permet donc de créer un kaléidoscope.
L’image d’origine est celle-ci :

void repeteLimage(PImage g){ 
  image(g,0,0); 
  pushMatrix();
  translate(width,0);
  scale(-1,1);
  image(g,0,0);
  popMatrix();
  pushMatrix();
  translate(width,height);
  scale(-1,-1);
  image(g,0,0);
  popMatrix();
  pushMatrix();
  translate(0,height);
  scale(1,-1);
  image(g,0,0);
  popMatrix(); 

}

L’image finalement obtenue à l’écran est celle-ci :

Powered by WordPress