ISMA303


Growing & Shrinking Circle

by Haig. Average Reading Time: less than a minute.

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;
}
}

No comments on ‘Growing & Shrinking Circle’

Leave a Reply