Fill Colour auf a Rectangle

I'm looking for an example to change the fill color of a rectangle. For example, when changing a boolean from 0 to 1, the content of the rectangle should change from red to green. furthermore, the rectangle should be adaptable in size.

Found an example for you