Wednesday, August 14, 2013

Processing exercise: draw rotated and translated image

Processing exercise: draw rotated and translated image
Processing exercise: draw rotated and translated image


PImage myImage;

void setup() {
  myImage = loadImage("http://goo.gl/MMeu0o", "png");
  size(400, 400);
  smooth();
}

void draw() {
  //draw in rotated/translated
  rotate(PI/4.0);
  translate(100, 0);
  image(myImage, 0, 0);
  
  //back to original 
  translate(-100, 0);
  rotate(-PI/4.0);
  
  //draw image in half size
  image(myImage, 0, 0, myImage.width/2, myImage.height/2);
}


No comments:

Post a Comment