Guest User

Untitled

a guest
Nov 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. /*
  2.  
  3. Digital Thaumatropes
  4. Created: November, 15, 2018
  5. Author: Verity Griscti
  6. Version: 1.0
  7.  
  8. This program is meant to recreate the optical illusion of analog thaumatropes and export the ouput to a gif.
  9. (press mouse button to end gif loop)
  10.  
  11. Two images of the thaumatrop are required (Back & Front). Images must be saved in the same file as the pde.
  12. The script alternates between the two of them quickly recreating the optical illusion.
  13.  
  14. The output is saved as a .gif Animation so it can be shared easily over the web.
  15.  
  16. The gifAnimation library is required for this to work.
  17. */
  18.  
  19. import gifAnimation.*;
  20. GifMaker gifExport;
  21.  
  22. int count = 1;
  23.  
  24. void setup(){
  25. size(290,175);
  26. gifExport = new GifMaker(this, "Digital_Thaumascope.gif");
  27. gifExport.setRepeat(0); //= loop forever
  28. }
  29.  
  30. void draw(){
  31.  
  32. if(count%2 == 0){
  33. PImage back;
  34. back = loadImage("InsertImageNameHere.jpg");
  35. if(count == 2 || count == 4){
  36. frameRate(2);
  37. }else{
  38. frameRate(15);
  39. }
  40. image(back,0,0);
  41. } else {
  42. PImage front;
  43. front = loadImage("InsertImageNameHere.jpg");
  44. if(count == 1 || count == 3){
  45. frameRate(2);
  46. }else{
  47. frameRate(15);
  48. }
  49. image(front,0,0);
  50. }
  51.  
  52. count = count + 1;
  53.  
  54. gifExport.setDelay(1);
  55. gifExport.addFrame();
  56.  
  57. }
  58.  
  59. void mousePressed(){
  60. gifExport.finish();
  61. }
Add Comment
Please, Sign In to add comment