/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://cst1101.sketchpad.cc/sp/pad/view/ro.bKaxrQcHVrC/rev.171
*
* authors:
* Joe Perrino
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/* homework #8
by joe perrino */
Circle[] j = new Circle[1];
int p = 0;
void setup()
{
background(255);
size(500,500);
}
void draw()
{
background(255);
if(p == 1)
{
for(int i = 0;i < j.length;i++)
{
j[i].display();
}
}
}
void mousePressed()
{
int l = j.length;
if(j[l-1] == null)
{
j[l-1] = new Circle(color(int(random(255)),int(random(255)),int(random(255))),int(random(40)),mouseX,mouseY);
}
else
{
j = (Circle[]) expand(j,(j.length + 1));
j[l] = new Circle(color(int(random(255)),int(random(255)),int(random(255))),int(random(40)),mouseX,mouseY);
}
p = 1;
}
class Circle
{
color c;
int r,x,y;
Circle(color _c, int _r, int _x, int _y)
{
c = _c;
r = _r;
x = _x;
y = _y;
}
void display()
{
ellipseMode(CENTER);
stroke(c);
fill(0,0);
ellipse(x,y,r*2,r*2);
}
}