topical media & game development

talk show tell print

graphic-processing-site-examples-Libraries-PDF-Export-MousePress-MousePress.pde / pde



   
Mouse Press. Saves one PDF of the contents of the display window each time the mouse is pressed.

  
  
  import processing.pdf.*;
  
  boolean saveOneFrame = false;
  
  void setup() {
    size(600, 600);
    frameRate(24);
  }
  
  void draw() {
    if(saveOneFrame == true) {
      beginRecord(PDF, "Line.pdf"); 
    }
    
    background(255);
    stroke(0, 20);
    strokeWeight(20.0);
    line(mouseX, 0, width-mouseY, height);
    
    if(saveOneFrame == true) {
      endRecord();
      saveOneFrame = false; 
    }
  }
  
  void mousePressed() {
    saveOneFrame = true; 
  }
  
  


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