# Very basic traffic light

**URL:** <https://discourse.processing.org/t/very-basic-traffic-light/24451>\
**Category:** Beginners\
**Tags:** homework\
**Created:** [October 8, 2020, 8:41pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451 "2020-10-08T20:41:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rk0945](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rk0945](https://discourse.processing.org/u/rk0945)\
**Post date:** [October 8, 2020, 8:41pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451/1 "2020-10-08T20:41:56Z")

</div>

Thanks - problem solved!!!

---

<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:** [October 8, 2020, 8:48pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451/2 "2020-10-08T20:48:08Z")

</div>

black is fill (0, 0, 0); OR fill (0);

---

<div class="post-metadata">

**Author:** ![rk0945](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rk0945](https://discourse.processing.org/u/rk0945)\
**Post date:** [October 8, 2020, 8:51pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451/3 "2020-10-08T20:51:31Z")

</div>

Yes, but in this case it makes the whole rectangle fill black, I want the rectangle colour to be different from text colour

---

<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:** [October 8, 2020, 8:52pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451/4 "2020-10-08T20:52:48Z")

</div>

I know

you have to say

```auto
fill ..... // set the color you want to have for the rect 
rect......
fill(0); // black 
text.......

```

for both situations, red light and green light…

---

<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:** [October 8, 2020, 8:54pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451/5 "2020-10-08T20:54:01Z")

</div>

Hey, and welcome to this forum!

Great to have you here!

😉

---

<div class="post-metadata">

**Author:** ![rk0945](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rk0945](https://discourse.processing.org/u/rk0945)\
**Post date:** [October 8, 2020, 8:55pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451/6 "2020-10-08T20:55:15Z")

</div>

Ah okay thanks I understand now. Thanks for your help!

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [October 10, 2020, 5:42pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451/7 "2020-10-10T17:42:51Z")

</div>

Do not change the title and body of your question after it was answered. Leave the original question there and accept Chrisir’s answer using the button next to his answer to help future visitors get an answer too 🙂

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 10, 2020, 7:51pm UTC](https://discourse.processing.org/t/very-basic-traffic-light/24451/8 "2020-10-10T19:51:00Z")

</div>

> [@rk0945](#):
>
> Thanks - problem solved!!!

You introduced another problem by removing the code from your post and changing topic title.

Please restore it.

Here is the last edit you removed:

## 

~~Very~~~~ basic ~~~~traffic~~~~ light~~

NAproblemsolved

boolean changeColour;

void setup() {  
changeColour = false;  
textSize (46);  
size (240, 300);  
}

void draw() {  
rect (40, 40, 160, 200);  
stroke (1);  
if (changeColour) {  
fill (0,200,0);  
text(“Walk”, 70, 150);  
}  
else

{ fill (200,0, 0);  
text(“Stop”, 70, 150);  
}  
}  
void mousePressed()  
{  
changeColour = !changeColour;  
}

**How do I make the text black so you can actually see it?**
