topical media & game development

talk show tell print

graphic-processing-learning-14-example-14-2-example-14-2.pde / pde



  // Learning Processing
  // Daniel Shiffman
  // http://www.learningprocessing.com
  
  // Example 14-2: Multiple translations
  
  void setup() {
    size(200,200);
    smooth();
  }
  
  void draw() {
    background(255);
    stroke(0);
    fill(175);
    
    // Grab mouse coordinates, constrained to window
    int mx = constrain(mouseX,0,width);
    int my = constrain(mouseY,0,height);
    
    // Translate to the mouse location
    translate(mx,my);
    ellipse(0,0,8,8);
    
    // Translate 100 pixels to the right
    translate(100,0);
    ellipse(0,0,8,8);
    
    // Translate 100 pixels down
    translate(0,100);
    ellipse(0,0,8,8);
    
    // Translate 100 pixels left
    translate(-100,0);
    ellipse(0,0,8,8);
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.