Simple Fade Out Fade In problem =/
in
Programming Questions
•
2 years ago
Hello,
i've made this code and i dont know where i made a mistake.
i made a image with 1000,1000 size and it has 4 equal areas. Each area should fade in/out a color if the mouse is in range.
Everything is working fine with 2 overlays. if I go over my 4 overlas everything is laggy and stop working =/.
Iam pretty new to processing
hope u can help me ;)
i've made this code and i dont know where i made a mistake.
i made a image with 1000,1000 size and it has 4 equal areas. Each area should fade in/out a color if the mouse is in range.
Everything is working fine with 2 overlays. if I go over my 4 overlas everything is laggy and stop working =/.
Iam pretty new to processing
hope u can help me ;)
- int ru = 0; // rightUP
int rd = 0; // rightDown
int lu = 0; // leftUP
int ld = 0; // leftDown
void setup() {
size(1000, 1000);
background(0);
}
void draw() {
if (mouseX > width/2 && mouseY < height/2)
{
ru = ru + 5;
constrain(ru, 0, 255);
rd = rd - 5;
constrain(rd, 0, 255);
lu = lu - 5;
constrain(lu, 0, 255);
ld = ld - 5;
constrain(ld, 0, 255);
}
if (mouseX > width/2 && mouseY > height/2)
{
rd = rd + 5;
constrain(rd, 0, 255);
ru = ru - 5;
constrain(ru, 0, 255);
lu = ru - 5;
constrain(lu, 0, 255);
ld = ld - 5;
constrain(ld, 0, 255);
}
if (mouseX < width/2 && mouseY < height/2)
{
lu = lu + 5;
constrain(lu, 0, 255);
ru = ru - 5;
constrain(ru, 0, 255);
rd = rd - 5;
constrain(rd, 0, 255);
ld = ld - 5;
constrain(ld, 0, 255);
}
if (mouseX < width/2 && mouseY > height/2)
{
lu = lu - 5;
constrain(lu, 0, 255);
ld = ld + 5;
constrain(ld, 0, 255);
ru = ru - 5;
constrain(ru, 0, 255);
rd = rd - 5;
constrain(rd, 0, 255);
}
fill(ld, 0, 0);
rect(0, 500, 500, 500);
fill(rd, 0, 0);
rect(500, 500, 500, 500);
fill(lu, 0, 0);
rect(0, 0, 500, 500);
fill(ru, 0, 0);
rect(500, 0, 500, 500);
stroke(255);
line(500, 0, 500, 1000);
line(0, 500, 1000, 500);
}
1