import gifAnimation.*;
GifMaker gifExport;
int z;
boolean a = true;
float hue;
int e;
void setup() {
  size(1000, 1000);
  background(255);
  frameRate(10);
  colorMode(HSB, 100);
  gifExport = new GifMaker(this, "/Users/Student/Desktop/explode.gif");
  gifExport.setRepeat(0);
  z = 1;
}
void draw() {
  noStroke();
  //z will be the frame count up until the frame count exceeds 100, upon which case it will reset to 1
  int i = 0;
  int j = 0;
  hue = frameCount%100;
  e = 6;

  //boolean a sets up a true/false statement. If the statement is true, loop will expand ellipses, if the statement is false, loop will contract ellipses.
  if (frameCount%100 == 0) {
    if (a) {
      a = false;
    } else {
      a = true;
      z = 1;
    }
  }

  //inverts the figure ground relationship of the subject and background depending on the x location of the mouse.
  if (mouseX < width/2) {
    background((hue+50)%100, 100, 100);
    fill(hue, 100, 100);
  } else {
    background(hue, 100, 100);
    fill((hue+50)%100, 100, 100);
  }
  //for (int z = 0; z<100; z = z+1) {
  //increases the location of the initial ellipse by adding the current frame count to the previous value of i. i begins at 0. 1 is added to i at frame 1. 2 is added (to i + 1) at frame 2. etc.
  if (a == true) {
    for (i = 0; i < width; i += z) {
      for (j = 0; j<360; j += 10) {
        pushMatrix(); 
        translate(width/2, height/2);
        rotate(radians(j));
        ellipse(i, i, e, e);
        noStroke();
        popMatrix();
      }
    }
  }
  //decreases the location of the initial ellipse by subtracting the remainder of the frame count after the modulo
  if (a == false) {
    for (i = 1089; i > 0; i -= z) {
      for (j = 0; j<360; j += 10) {
        pushMatrix();
        translate(width/2, height/2);
        rotate(radians(j));
        ellipse(i, i, e, e);
        popMatrix();
      }
    }
  }
  //}
  println("variable =", i);
  println(z);
  println(a);
  if (a == true) {
    z++;
  }
  if (a == false) {
    z--;
  }
  if (frameCount == 200) {
    gifExport.finish();
  } else {
    gifExport.setDelay(1);
    gifExport.addFrame();}
  }

You may also like

Back to Top