code:
int pointX = 0;
int pointY = 0;
int ewidth = 0;
int elength = 0;
void setup(){
size(640,480);
background(100,50,50);
}
void draw(){
stroke(200,0,0);
strokeWeight(5);
fill(1,200,1);
stroke(106,13,170);
rect(320,240,300,200); //rectangle
stroke(0,200,200);
strokeWeight(1);
fill(1,1,200);
stroke (random(200),random(200),random(200)); // random outline color of the ellipse
ellipse(300 + pointX,260 + pointY,40 + ewidth,40 + elength); // creates a variable dependent ellipse
}
void keyPressed() {
if (keyCode == RIGHT) {
//noStroke();
pointX = pointX + 1; // moves the ellipse to the right one pixel
ewidth = ewidth + 1; // increases the width of the ellipse every time it is moved to the right
}
else if (keyCode == UP) {
pointY = pointY-1; // moves ellipse up one pixel up
elength = elength + 1; // increases length of ellipse every time it is move up
}
else if(keyCode == LEFT){
pointX = pointX-1; // moves ellipse to the left one pixel
ewidth = ewidth – 1; //decreases width of ellipse every time it is moved to the left
}
else if(keyCode == DOWN){
pointY = pointY+1; // moves the circle down one pixel
elength = elength – 1 ; // shortens the length of the ellipse every time it is moved down
}
}
void mousePressed(){
if (mousePressed == true){
fill(random(200),random(200),random(200)); //random color
strokeWeight(random(8)); //random stroke weight of triangle between 0-8
triangle(mouseX,mouseY,random(200),random(200),random(200),random(200)); //creates triangle that starts at position of mouse
}
}