I am working on a Java Applet.
I have been trying to find a way to slightly blur the screen when an invalid action is preformed by the user.
My idea is this: redrawing the current background image slightly skewing where the image gets drawn by a few pixels and adjusting alpha as necessary.
example:
public void paint(Graphics gfx){ gfx.drawImage(buffer, xShake, yShake, this); } public void shake() { fade.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); fade.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); //adjust xShake and yShake somewhere in here (maybe) alpha += 0.10f; if (alpha >= 1.0f) { alpha = 0.0f; } else{ repaint(); } }
My question is now, how would you guys go about making the screen blur, the above attempt failed. If there is an existing java class that handles this, that would be great.
The above is just my current idea on how I might be able to do it, I don't know why it isn't working.
When I adjust xShake and yShake in the method, I have final image back in it's original position by the end of the method. When that's the case, no change happens on the applet. Otherwise, if I have xShake and yShake end at a spot other than the original, a mere fade occurs...
Any help is always appreciated, thank you!