Clearing to a colour with alpha

Hi
I’m working with xith3d and as part of the overlay package you can draw what you want right onto a Grahpics2D, i’m trying to create a component that is semi transparent, but then gets text placed on it, the text will update so when it does I need to rewrite the bits behind the text to remove the old stuff.
I’ve tried graphics.setBackground(new Color(0,0,0,0)); graphics.clearRect(0,0,width-1,height-1); but it doesn’t seem to actually clear it. So i tried graphics.setColor(new Color(0,0,0,0)); graphics.fillRect(0,0,width-1,height-1); but that doesn’t seem to do it either. It has been suggested that the reason it has no effect is because the colour has an alpha of 0. Is there any way I can wipe the graphics 2D to have 0,0,0,0 in all pixels?

Cheers

Endolf

g2d.setComposite(AlphaComposite.Src);
g2d.setColor(new Color(0x00000000,true));
g2d.fillRect(0,0,width,height);

Hi
I tried it and that didn’t work either, I went back to my old code and as well as drawing to the graphics object I get passed, I drew to one from a buffered image which I wrote to disk each update (once a second). And it was all working fine, the alpha channel was present, the background colour was right, and the text wasn’t overdrawn but cleared and redrawn on each image, I guess this isn’t a java2d issue.

Thanks anyway

Endolf


      g.setComposite(AlphaComposite.Clear);
      g.fillRect(0, 0, w,h);

Should definitely work.

Cheers,

Mik

Hi
The code I have works, at least on the images dumped to disk, it’s looking like it might be a xith3d issue as Jens is having similar problems.

Endolf

Yeah, we had a bug preventing this from working properly in some cases. Fixed in 1.5, I believe.