Skip to main content

drawing semi-transparent polygons leaves remnants along border edges

2 replies [Last post]
brian101
Offline
Joined: 2010-03-22
Points: 0

I am drawing a complex image made up of a lot of polygons. These polygons are made up of a series of triangles and occasionally where they join along the edges it appears as though the line drawing algorithms may be off by a pixel. When this happens it leaves remnants where the triangles edges come together. Sometimes this remnant is the background color of the window (e.g. neither polygon shaded this area). Sometimes it is an overlap causing the edge line to show up darker than either shaded polygon.

I have done a lot of checking and here is what I have tried so far...to no avail...
I have tried all the various combinations of the rendering hints listed below...
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);

When that didn't work I tried setting ALL the integer coordinates that were rendered to even numbers (and odd numbers... i tried both) based on some reading I did onlline about people having some line draw issues...

Anyway any ideas about how to solve this would be greatly appreciated. If it helps anyone I can attach an image that shows what I'm dealing with.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
claudeabb
Offline
Joined: 2006-08-09
Points: 0

HI,

As you draw lines you should let the antialiasing set on.

You can also try to combine the renderinghints herefater:

- KEY_DITHERING
- KEY_COLOR_RENDERING

Have you tried to change the AlphaComposite mode in which the drawing is done?

brian101
Offline
Joined: 2010-03-22
Points: 0

Well I tried everything...after many many many grueling hours of debugging and trial and error I stumbled across a portion of my code where when something that was interpolated using two different purposes/methods which should be exactly the same would compute to an ever so slightly different double value which in turn would occasionaly be mapped to device units that were 1 pixel different. This had been in my code for years (albiet in other programming languages) but since the older versions didn't support semi transparent polygons a multitude of sins were covered up I guess.

Thanks for responding. I would have cancelled my message or marked it as answered but I only figured this out late last night.