Advertisement
xeromino

moons

Jan 30th, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. int num=8, cols=8, edge=50;
  2. PImage[] moon = new PImage[num];
  3. int c=0;
  4.  
  5. void setup() {
  6. size(500, 500);
  7. int counter = 189;
  8. for (int i=0; i<num; i++) {
  9. String img = counter + ".png";
  10. println(img);
  11. moon[i]=loadImage(img);
  12. counter++;
  13. }
  14. frameRate(5);
  15. }
  16.  
  17. void draw() {
  18. background(20);
  19. for (int x=0; x<cols; x++) {
  20. for (int y=0; y<cols; y++) {
  21. float px = map(x,0,cols,edge,width-edge);
  22. float py = map(y,0,cols,edge,height-edge);
  23. paintMoon(px, py,int(x), int(y));
  24. }
  25. }
  26. if (frameCount<=num) saveFrame("image-###.gif");
  27. }
  28.  
  29. void paintMoon(float x, float y, int offX, int offY) {
  30. pushMatrix();
  31. translate(x, y);
  32. image(moon[(frameCount+offX)%num], 0, 0,50,50);
  33. popMatrix();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement