this is what i’m trying to do:
- Create a program that will change the background color based on the mouse.
- You will create a setup(), draw() function. The size of the frame will by 400 by 400.
- Create a mousePressed() function . Check to see if the RIGHT or LEFT mouse button has been pressed. Change the background color to red if the LEFT mouse is pressed and blue if the right mouse is pressed.
- Create a mouseReleased() function. Change the background to yellow.
- Create a mouseMoved() function. Change the background to green.
- Create a mouseDragged() function . Change the background to white.
**Can you check my code to see if it works right? **
void setup()
{
size (400, 400);
}
color c1=color(255, 0, 0);//red, left
color c2=color(0, 0, 255);//blue, right
color c3=color(255, 255, 0);//yellow
color c4=color(0, 255, 0);//green
color c5=color(255, 255, 255);//white
void draw()
{
mousePressed();
background (0);
println("mouse was pressed", width, height);
if(mouseButton ==LEFT)
{
background(c1);
println("and it was the left button", width, height);
}
println("mouse was pressed", width, height);
if(mouseButton ==RIGHT)
{
background(c2);
println("and it was the right button", width, height);
}
}
void mouseReleased()
{
background(c3);
}
void mouseMoved()
{
background(c4);
}
void mouseDragged()
{
background(c5);
}