xeromino

eclipse

Nov 14th, 2013
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. float x, y, org_x, org_y;
  2. float theta, diam_sun, orbit_moon, diam_moon, radius;
  3. color bg = #100315;
  4. color f = #FCFCFC;
  5.  
  6. void setup() {
  7.   size(500, 500);
  8.   background(bg);
  9.   noStroke();
  10.  
  11.   org_x = width/2;
  12.   org_y = height/2;
  13.  
  14.   diam_sun = 150;
  15.   diam_moon = diam_sun*.95;
  16.   orbit_moon = diam_sun - diam_moon ;
  17.  
  18.   radius = orbit_moon/2 + 3;
  19. }
  20.  
  21. void draw() {
  22.   background(bg);
  23.   fill(f);
  24.   ellipse(org_x, org_y, diam_sun, diam_sun);
  25.   fill(bg);
  26.  
  27.   x = org_x + sin(theta)*radius;
  28.   y = org_y + cos(theta)*radius;
  29.  
  30.   ellipse(x, y, diam_moon, diam_moon);
  31.  
  32.   theta += 0.0523;
  33.  
  34.   if (frameCount % 4 == 0 && frameCount <121) saveFrame("image-####.gif");
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment