

Spot [] sp= new Spot [100];void setup(){
size (500,900);
smooth();
noStroke();
for(int i=0; i<50; i++){
sp[i] = new Spot(random(width),random(height),random(10,50), color(int(random(255)),0,0) ); //construct the object
}
}
void draw(){
background(0);
for(int i=0; i<50; i++){
sp[i].display();
}
}
class Spot{ //declaring a new class named spot
float x, y; //the x- and y-coordinate
float diameter; //diameter of the circle
color fColor;
//constructor so that the beginning spot at top doesn't need
//the excessive variables listed - it gets information from here.
Spot(float xpos, float ypos, float dia, color fillColor){
x=xpos;
y=ypos;
diameter=dia;
fColor=fillColor;
}
void display(){
fill(fColor); //changes colors of dots
ellipse (x,y,random(diameter),random(diameter));
}
}
void keyPressed(){
if (key=='s'){
saveFrame("week3-####.jpg"); //saves the image in documents
}
}
No comments:
Post a Comment