halo effect in java2d
I am drawing a small indicator widget over anot开发者_Go百科her visual representation of a system.
This widget is essentially an altitude indicator: a vertical bar and a triangle that points at the current camera altitude. In crude ascii art:
|
|<
|
|
|
More often than not, visibility is hampered by the layer below. Is there an easy way to create an aesthetically pleasing white "halo" around my widget in java2D?
Cheers
In my application, I draw lines with a thickness of three pixels in white, then again with a thickness of one pixel in red. Experiment with the widths, line cap style and anti-aliasing rendering hints to get something that looks good to you.
Achieving halos for text is more difficult: you have to call
Font.createGlyphVector
to get the outline of the characters,
draw the outlines as lines in white and then draw the string over the
top in red using Graphics2D.drawString
.
精彩评论