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 › Always use background when using text
Page Index Toggle Pages: 1
Always use background when using text (Read 396 times)
Always use background when using text
Sep 9th, 2008, 4:09pm
 
Thanks for the terrific work being done on (and with!) processing. I have used it for some time now, with great pleasure. I have a (minor) question about anti-aliased text.

I noticed recently that anti-aliased text looked fine when I put the text over say a rect. However, when directly placed on the sketch, the same text looked pretty awful.

It took me some time to figure out that a simple way to resolve this (much simpler than putting invisible rects under my texts), was to always start draw() with a background() call. I just assumed I had not read the documentation carefully enough to notice this requirement, and was happy to proceed. However, I now notice that some of the examples included in the (148) distribution (e.g. the Examples/Basic/Typography sketch) come without a background() call, and that they also look pretty awful until I add a background call. So what's up? I am using the Windows + java version "as it came out of the box".

Thanks, Jos de Bruin

==============

void setup(){
 fill(0);
 textFont(loadFont("ArialMT-12.vlw"));      //not OK
 //textFont(createFont("SansSerif", 12, false));   //OK
 background(100);   // does not help
}
void draw(){
 //background(100);  //solves the problem
 fill(210);
 rect(10,10, 50,50);
 fill(0);
 text("Text", 30, 30);  //always OK
 text("Text", 65, 65);  //only in combination with background()
}
Re: Always use background when using text
Reply #1 - Sep 9th, 2008, 7:06pm
 
yuck, if out of the box examples are doing that, please file a bug at dev.processing.org/bugs. it's probably a remnant of very old examples where draw() meant that it only ran once, while code inside loop() made it run several times.

to fix the example, you can either use background(), or to see it as intended, add noLoop() to setup().

there are likely others that behave this way, so if someone would like to help us out, please check the others to see if there are any that we missed (and file a bug for them).
Re: Always use background when using text
Reply #2 - Sep 9th, 2008, 9:35pm
 
OK, so the anti-aliasing goes haywire when done repeatedly without first redrawing the surroundings pixels. That makes sense, sorry, never gave anti-aliasing any serious thought. I guess I will have to make amends by helping out with the examples, I will try to look at them in the coming days.

regards, Jos
Page Index Toggle Pages: 1