# Fill not overwriting the last fill

**URL:** <https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491>\
**Category:** Coding Questions\
**Created:** [March 1, 2022, 6:16am UTC](https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491 "2022-03-01T06:16:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bepishibe](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@Bepishibe](https://discourse.processing.org/u/Bepishibe)\
**Post date:** [March 1, 2022, 6:16am UTC](https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491/1 "2022-03-01T06:16:29Z")

</div>

so im trying to make a code for a school project where the german empire flag turns into the german flag when i drag on it.

until the second ellipse(mouseX,mouseY,50,50); part, everything works fine, but in the if(200 \<= mouseY \<= 300){ part, instead of coloring the ellipses 255,206,0 , it colors the ellipses. 221,0,0 .  
pls help

 ![スクリーンショット 2022-03-01 15.14.56](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8b588ff2ea889f5edef46ec83d36d7d2272917f3.png)

```auto
function setup(){
  createCanvas(500,300);
  frameRate(30);
   noStroke();
  fill(0,0,0)
  rect(0,0,500,100)
  fill(255,255,255);
  rect(0,100,500,100);
  fill(222,0,0);
  rect(0,200,500,100);
}
function draw(){
  if(mouseIsPressed == true){
    if(mouseY < 100){
      fill(0,0,0);
      ellipse(mouseX,mouseY,50,50);
    }else{
      if(100 <= mouseY <= 200){
        fill(221,0,0);
        ellipse(mouseX,mouseY,50,50);
      }else{
        if(200 <= mouseY <= 300);{
          fill(255,206,0);
          ellipse(mouseX,mouseY,50,50);
        }
      }
    }}
 
}

```

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [March 1, 2022, 6:26am UTC](https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491/2 "2022-03-01T06:26:44Z")

</div>

> [@Bepishibe](#):
>
> `100 <= mouseY <= 200`

Your if statements’ conditions are not right.

Try:

```auto
100 <= mouseY && mouseY <= 200
```

---

<div class="post-metadata">

**Author:** ![Bepishibe](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@Bepishibe](https://discourse.processing.org/u/Bepishibe)\
**Post date:** [March 9, 2022, 1:15pm UTC](https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491/3 "2022-03-09T13:15:46Z")

</div>

Thanks for the response  
What does that mean btw

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [March 10, 2022, 10:44am UTC](https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491/4 "2022-03-10T10:44:55Z")

</div>

> **[Reference](https://processing.org/reference/logicalAND.html)**
>
> Compares two expressions and returns true only if both evaluate to true. Returns false if one or both evaluate to false. The following list shows all possible combinations:…

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 10, 2022, 11:11am UTC](https://discourse.processing.org/t/fill-not-overwriting-the-last-fill/35491/5 "2022-03-10T11:11:04Z")

</div>

> [@Bepishibe](#):
>
> ` if(100 <= mouseY <= 200){`

You can’t write a condition this way.

Instead you need to check both numbers separately and connect both checks with AND which is && in Java processing.

Like here

`if (100 <= mouseY && mouseY <= 200)`

same as

(but better readable)

```auto
 if ( mouseY >= 100 && 
      mouseY <= 200 )

```
