xxxxxxxxxx
float xpos=0;
float ypos=0;
float rectW=100;
float rectH=100;
float rectStroke = 255;
float rectFill = 255;
float ellipseW=50;
float ellipseH=50;
float bkgdcolor = 255;
float change = .5;
void setup(){
background(bkgdcolor);
size(400,400);
smooth();
stroke(rectStroke);
fill(rectFill);
}
void draw(){
fill(rectFill); //fills the rectangle with color
rect(xpos, ypos, rectW, rectH); //creates a rectangle
ypos=ypos + change; //makes the rectangle change it's vertical position downward
rectH = rectH + change; //makes the height of the rectangle get bigger
variableEllipse(mouseX, mouseY, pmouseX, pmouseY);
}
//after drawing an ellipse, this section of code will create many ellipses upon moving the cursor. The faster you move the cursor the bigger the ellipses will get.
void variableEllipse(int x, int y, int px, int py) {
float speed = abs(x-px) + abs(y-py);
stroke(speed);
ellipse(x, y, speed, speed);
}
void mousePressed(){
background(random(255), random(255), random(255)); //fills the background with a random color when pressed
}
void mouseDragged(){
fill(random(255), random(255), random(255)); //fills the ellipse with a random color when dragged
ellipse(pmouseX, pmouseY, ellipseW, ellipseH); //creates an ellise that will move around the screen
}