topical media & game development

talk show tell print

graphic-processing-learning-17-example-17-5-example-17-5.pde / pde



  // Learning Processing
  // Daniel Shiffman
  // http://www.learningprocessing.com
  
  // Example 17-5: Rotating text 
  
  PFont f;
  String message = "this text is spinning";
  float theta;
  
  void setup() {
    size(200,200);
    f = createFont("Arial", 20, true);
  }
  
  void draw() {
    
    background(255);
    fill(0);
    textFont(f);                 // Set the font
    translate(width/2,height/2); // Translate to the center
    rotate(theta);               // Rotate by theta
    textAlign(CENTER) ;
    
    // The text is center aligned and displayed at (0,0) after translating and rotating. 
    // See Chapter 14 or a review of translation and rotation.
    text(message,0,0); 
    
    // Increase rotation
    theta += 0.05; 
  }
  


(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.