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 & HelpPrograms › Background() Not always working with java export
Page Index Toggle Pages: 1
Background() Not always working with java export? (Read 794 times)
Background() Not always working with java export?
Oct 25th, 2006, 6:46pm
 
Hi-

New to the board and new to Processing (or is it Proce55ing/)

I made a version of the "TIX" clock (here at my web site: http://ffaat.pointclark.net/blog/archives/116-The-TIX-Clock-and-Processing-1.0.h...

When exported as a Java applet, the background colour doesn't always get set right.  It sometimes ends up as white, rather than the grey I coded.

My set-up code is here:
Code:

int bg_col = 64;

// The statements in the setup() function
// execute once when the program begins
void setup()
{
size(200/14*14, int(200/14*5)); // Size should be the first statement
colorMode(HSB,255);
stroke(64); // Set line drawing color to grey

background(bg_col); //doesn't always work?
fill(bg_col);
rect(0, 0, width, height); //try to fix the background

stroke(128); // Set line drawing color to grey
sq_col=color(0,255,255);
bg_col=color(0);
}


I even edded the extra rect() to try to force it to draw the bacground, but that also doesn't also work (all the time)

Any thoughts or suggestion?  The full code can be downloaded by following the link at the end of the blog entry.

Thanks in advance,

-Rob A>
Re: Background() Not always working with java expo
Reply #1 - Oct 26th, 2006, 9:33pm
 
If you want to use HSB, try making bg_col a color instead of an int.  Then set it to : color(0,0,64)  .  (Hue is irrelevant, No Saturation, 1/4 brightness).

Also put the background() call in your draw() instead of setup().

Re: Background() Not always working with java expo
Reply #2 - Oct 27th, 2006, 5:21pm
 
Thanks -
I have changed the int defs to color and am always using the full HSB in calls, but it still doesn't always work.

It will allways work if I move the background call into the draw() function bu I don't think it should need that...

The documentation fort background() states:
The background() function sets the color used for the background of the Processing window. The default background is light gray. In the draw() function, the background color is used to refresh the display window between frames.

Which to my mind means that if background() is called once in the setup() routine, and never called again, Processing should still redraw the bg with that color every time draw() executes without having to reset it...

Is this a bug?

-Rob A>
Re: Background() Not always working with java expo
Reply #3 - Oct 27th, 2006, 8:15pm
 
I'm afraid you're misinterpreting the reference, if you don't put a background call in draw, the screen won't be cleared between frames, and everything will leave trails.
Page Index Toggle Pages: 1