Advertisement
xeromino

gifExample

May 11th, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. int frms = 200;  // number of frames of the animation
  2. float theta = 0; // the angle used for the loop
  3.  
  4. void setup() {
  5.   size(500,500);
  6. }
  7.  
  8. void draw() {
  9.   background(0);
  10.   float x = map(sin(theta),-1,1,100,400); // mapping the sine of the angle to a position
  11.   ellipse(x,height/2, 50,50);
  12.   float inc = TWO_PI/frms; // dividing the circle by the number of frames that we want
  13.   theta += inc;  // increasing the angle by this amount
  14.   if (frameCount < frms) saveFrame("image-###.gif");
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement