Filled Rectangle override each other in paint

Hello Friends,

I want to draw three rectangle of same size overriding each other
// g.setopacity(0.5f)
But each rectangle are overriding each other, so I can’t see now that over the last rectangle where other two rectangles are. I want my all rectangle to be transparent so that i can see each rectangle’s boundary(Yeah colour override will change original colour but boundary can help). I need result like following image

{In above image only three rectangles are there, below one is Red, second is green and third is blue[they are like six but they are overrided to each other]}

I tried to get it using setOpacity to different rectangle fill, and also tried generic opacity set to 0.5f for all fillrect but didn’t get right one.

Thanks Juiciest.

You could set a different alpha value for each colour.
Something like this:


The opacity comes from the current colour.
setOpacity changes the opacity of the current colour.
If you call setColour, it will change the current colour (and thus whatever opacity you have set with setOpacity).

You should either create your colours with the opacity required, or call setColour THEN setOpacity.

Thanks much masshacker and haydxn. That solves my problem and also doubts to regarding opacity and colour.
What i was doing was setting opacity and defining colour and again set it beck to 1 opacity, that was not making the effect i wanted.
THanks for help.