# Exercise 32

## June 18, 2015 by Haig. Average Reading Time: less than a minute.

Instead of just telling Processing to draw a circle, let’s instead create a circle object. The circle object will encapsulate everything there is to know about itself, which at the moment isn’t much more than the x,y of its center point, and its radius.

``````
class Circle {
float x, y;
color linecol, fillcol;
float alph;
Circle () {
x = random(width);
y = random(height);
linecol = color(random(255), random(255), random(255));
fillcol = color(random(255), random(255), random(255));
alph = random(255);
}
}
``````

Then we need to change our drawCircles function to this:

``````
void drawCircles() {
for (int i=0; i<_num; i++) {
Circle thisCirc = new Circle();
}
}
``````

Still no circles been draw because we haven’t put the draw function into the circle class:

``````

class Circle {
float x, y;
color linecol, fillcol;
float alph;

Circle () {
x = random(width);
y = random(height);
linecol = color(random(255), random(255), random(255));
fillcol = color(random(255), random(255), random(255));
alph = random(255);
}
void drawMe() {
noStroke();
fill(fillcol, alph);
stroke(linecol, 150);
noFill();
ellipse(x, y, 10, 10);
}
}
``````

And finally we must update the drawCircles() function

``````
void drawCircles() {
for (int i=0; i<_num; i++) {
Circle thisCirc = new Circle();
thisCirc.drawMe();
}
}``````