I've run into this problem a couple of times during my programming career. In my case it was adding text overlays to images to show additional image meta data... while fighting the Sith with Jonny Depp! It's actually surprisingly easy to get text to show up nicely on almost any background. All you need to do is have lightly coloured text with a shadow effect.
The simplest way to do this is to simply paint a copy of the text in question one pixel down and one to the right in black. For added readability add another copy one pixel to the right.
Here's some sample code:
g.setColor(Color.BLACK);
g.drawString(TEXT, 10 + 1, 10 + 1); //second shadow
g.drawString(TEXT, 10 + 1, 10); //first shadow
g.setColor(Color.WHITE);
g.drawString(TEXT, 10, 10);
Nice, large, translucent drop shadows can also increase the readability of text. In my case, though, I only want the shadow effect to increase the readability of the text. The simplicity and subtlety of the shadow effect above is a feature.
I've included a real time java demo of just how amazing this effect can be.
Shadowed text demo!
(Requires java. Open the file with the "java web start" application)
Source code is here!
For those without java this is what the incredibly light pink text looks like on a pure white background:
(The application isn't this blurry when you run it :-) )
Google makes use of a subtle and more fancy shadow effects if you select a background for you Google homepage. You can use any photo for the background. In this image I've selected a plain, white background:
No comments:
Post a Comment