Search code examples
javagraphicsalphagraphics2d

Java - Rubber alpha function


I am currently making a paint program, and am currently implementing a rubber tool (a version which works with alpha colors). The problem is, I can't paint invisible lines via mouseDragged event because they will just go on top of the painting that was there before...

I have considered setRGB on bImg, but it would need to be supported by mouseDragged and also make the thickness of the line variable. Anyone got any ideas?

EDIT: Why down votes?


Solution

  • You could convert your image to a writeableraster and use getpixel() and setpixel() methods to convert the colors underneath the user's mouse-pointer under certain conditions.