Very basic traffic light

Thanks - problem solved!!!

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

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

I know

you have to say

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

for both situations, red light and green light…

Hey, and welcome to this forum!

Great to have you here!


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

1 Like

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 :slight_smile:


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


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);

{ 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?