Clip region edge match: bug or feature?
Greetings! I'm trying to implement simple one-color Gouraud-shaded triangles with Graphics2D primitives and no OpenGL . This is a low performance graphics fallback option for the (apparently) many video cards out there that don't play very well with JOGL, which is the main rendering path.
I'm building a color gradient in a BufferedImage and then using drawImage(bufferedImage, AffineTransform, Observer) and setClip() to the triangle. The affine transform does a triangle-to-triangle mapping to put the right swatch of pixels in the unclipped region.
There is no transform applied to the clipping region.
This all works very nicely and is easily fast enough except...
One problem: There are white pixels sprinkled along the boundaries between triangles.
This indicates that clip region edges given with exactly the same vertices don't mesh perfectly as polygon edges do. Argh...
Odd thing: tried painting each triangle 4 times: at normal location plus one pixel east, north, and northeast, expecting this to be a brute force solution. No joy. The white pixels are still there. Moreover, set the JPanel background to dark gray and the bad pixels turned that color. So it appears that pixels just outside the clip boundary are being painted with the _component_ background.
So this is starting to look like an image clipping bug or anti-aliasing getting in the way (I tried hints to turn aa off, but again no joy) or else something about the API I'm not getting.
Before I toss this painfully close-but-no-cigar attempt and move on to another, does anyone have ideas?
I can post code, but someone else seems to have run into the same behavior and already has posted an example: