We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Re: Overlapping and different fill colours
Page Index Toggle Pages: 1
Re: Overlapping and different fill colours (Read 198 times)
Re: Overlapping and different fill colours
Feb 14th, 2009, 1:39am
 
Processing (like PDF and PostScript) uses a model where there is one global fill color (and stroke color) at all times.  That color applies to all subsequent drawing actions, until changed to something else.  So to make the rectangle a different color than the stuff that was drawn previous to it, you need to put a fill() call right before it.  Assuming you want the circles that's drawn after the rectangle to be the same as the circles that came before, you must then restore the fill to its previous setting.  So if you change these lines:

{
rect(160,0,140,90);
}

to this (by the way, you don't need the braces around the rectangle call for anything, so I got rid of them), you'll see what I mean:

// Make the rectangle red, just to make the change obvious:
fill(255,0,0,128);
// Draw it:
rect(160,0,140,90);
// Now restore the transparent green fill:
fill(178,255,0,190);
Re: Overlapping and different fill colours
Reply #1 - Feb 14th, 2009, 1:44am
 
Shocked Thank you so much! Smiley
Page Index Toggle Pages: 1