Basic Processing Sketch for Image making/experimentation


/ Published in: Processing
Save to your folder(s)

This is an slightly more involved processing basic sketch I use when creating Imagery so I can save and output images at any point in time when the sketch is running.


Copy this code and paste it in your HTML
  1. import processing.pdf.*;
  2.  
  3. boolean isMakingPdf = false;
  4.  
  5. void setup(){
  6. }
  7.  
  8. void draw(){
  9. if(isMakingPdf){
  10. beginRecord(PDF, "frame-####.pdf");
  11. }
  12.  
  13. //draw stuff
  14.  
  15. if(isMakingPdf){
  16. endRecord();
  17. isMakingPdf = false;// stop pdf creation after the frame ends
  18. }
  19. }
  20.  
  21. void keyPressed(){
  22. //save PDF when you hit the o key
  23. if(key == 'o'){
  24. isMakingPdf = true;
  25. }
  26.  
  27. //save jpg image when you hit the s key
  28. if(key == 's'){
  29. saveFrame("frame-####.jpg");
  30. }
  31. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.