Growing & Shrinking Circle


int diam = 10;
float centX, centY;
boolean growth;

void setup() {
  size(600, 600);
  frameRate(24);
  smooth();
  background(180);
  centX = width/2;
  centY = height/2;
  stroke(0);
  strokeWeight(5);
  fill(255,50);
}

void draw() {
  if (growth) {
    bigger();
  } else {
    smaller();
  };
}

void bigger() {
    background(180);
    ellipse(centX, centY, diam, diam);
    diam += 10;
    if (diam >=width) {
      growth = false;

    }
}

void smaller() {
    background(180);
    ellipse(centX, centY, diam, diam);
    diam -= 10;
    if (diam <=10) {
    growth = true;
    }
}

int diam = 10;
float centX, centY;
boolean growth;

void setup() {
size(600, 600);
frameRate(24);
smooth();
background(180);
centX = width/2;
centY = height/2;
stroke(0);
strokeWeight(5);
fill(255,50);
}

void draw() {
if (growth) {
bigger();
} else {
smaller();
};
}

void bigger() {
background(180);
ellipse(centX, centY, diam, diam);
diam += 10;
if (diam >=width) {
growth = false;

}
}

void smaller() {
background(180);
ellipse(centX, centY, diam, diam);
diam -= 10;
if (diam <=10) {
growth = true;
}
}


Leave a Reply

Your email address will not be published. Required fields are marked *