User Tools

Site Tools


cs276:rotatesandwich
/*
 * Rotate Sandwich
 *
 * Demo of how to grab the contents of the display window and rotate it
 *
 */
 
PImage img, doit;
float rotation = 0;
 
void setup() {
  //img = loadImage("http://www.tellys.com/images/plants/annuals/mums_apricot_200x200.jpg");
  //image(img, 0, 0);
  smooth();
  strokeWeight(8);
  line(0, 0, width, height);
  line(0, height, width, 0);
  noStroke();
  ellipse (18, 50, 16, 16);
 
  // Key Point! 
  // Copy current display window contents to a PImage
  doit = get();
  frameRate(20);
}
 
void draw() {
  background(204);
  translate(width/2, height/2);
  rotation += PI/8;
  rotate(rotation);
  image(doit, -width/2, -height/2);
}
cs276/rotatesandwich.txt · Last modified: 2007/12/07 12:15 by scarl