This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes Applet graphics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet graphics" Watch "Applet graphics" New topic

Applet graphics

Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Hi, I was wondering if anyone knows how to create a partially erased effect that would partially reveal the images/color underneath?
Sean MacLean
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
Here's a suggestion that may give you a direction to start off in. Firstly, have a look at some tutorials on ImageFilters. They are a really handy way of manipulating Images. I'll outline the steps that I think will get you going:
1) Define the area that you want to be erased and create and Image object out of it.
2) Create a custom "EraseFilter" by extending java.awt.image.RGBImageFilter.
3) Design the filter so that, upon instantiation, it holds the foreground color and the backgraound image in arrays. Make the foreground the solid color you want to erase.
4) Define a mousehandler that is aware of the bounds of the Image you want to erase over.
5) Have the mouseEvent set it's coordinates in the filter as it erases and after some predetermines distance (1 pixel, 10 pixels, whatever is smooth) call filterRGB.
6) Within the filterRGB() method (in the ImageFilter), swap the foreground pixels to the background pixels of the image ( that you have stored in arrays in the ImageFilter, remember?)
7) call repaint (or have the filterRGB in the repaint()) and simple call g.drawImage( ..... ) on the original image. Magically the newly erased bits will appear.
This is similar to an ImageFade thing that I did in that I started with two Images - one on top of the other - and then looped using the filterRGB() to mathematically fade the pixel values from one image to the other. Worked like a charm and was really smooth. Good luck and have fun!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Applet graphics
Similar Threads
OOP,Pointers,Inheritance in Java
doubt in connection url for oracle 10g express edition
WA #1.....word association
migrating from ejb to spring
Any way of getting around the "Rational certs only for partners" thing?