Animation zum Verschwinden eines Bildes

KingR

Grünschnabel
Hi, hab schon in Google gesucht aber nichts gefunden, ich suche nämlich einen Quellcode oder einen Algorithmus für eine Awt-Animation für das Verschwinden eines Images. Sowas wie ein plopp und dann ist des Bild weg oder etwa eine Explosion. Vielleicht hat ja einer von euche eine Idee. Danke schon mal im voraus
 
Hallo!

Meinst du sowas?

Bilder ein und ausfaden
Code:
package de.tutorials;

import java.awt.AWTException;
import java.awt.AlphaComposite;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

public class AWTFadout extends Frame {

	private BufferedImage img, screenImg;

	private BufferStrategy strategy;

	private Rectangle rect;

	private Thread fader = new Thread() {
		{
			setPriority(MIN_PRIORITY);
		}

		public void run() {
			int alpha = 100; //int alpha = 0; //einfaden
			while (alpha-- > 1) { //while(alpha++ < 100){ //einfaden
				try {
					Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
					g.clearRect(rect.x, rect.y, rect.width, rect.height);
					g.drawImage(screenImg, 0, 0, null);
					g.setComposite(AlphaComposite.getInstance(
							AlphaComposite.SRC_OVER, alpha / 100.0F));
					/*
					 		Einfaden...
					 		g.setComposite(AlphaComposite.getInstance(
					 			AlphaComposite.SRC_OVER, alpha / 100.0F));
					 
					 */
					g.drawImage(img, 0, 0, null);
					g.dispose();
					strategy.show();
					Thread.sleep(50L);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	};

	public AWTFadout() {
		super("AWTFadout");
		setUndecorated(true);
		setIgnoreRepaint(true);
		try {
			img = (BufferedImage) new ImageIcon(ImageIO.read(new File(
					"c:/Beispiel.jpg"))).getImage();
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		int w = img.getWidth();
		int h = img.getHeight();

		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

		Point p = new Point(d.width / 2 - w / 2, d.height / 2 - h / 2);
		rect = new Rectangle(p.x, p.y, w, h);

		try {
			Robot robot = new Robot();
			screenImg = robot.createScreenCapture(rect);
		} catch (AWTException e) {
			e.printStackTrace();
		}
		setSize(rect.getSize());
		setLocation(p);
		setVisible(true);
		createBufferStrategy(2);
		strategy = getBufferStrategy();
		fader.start();
		try {
			fader.join();
		} catch (InterruptedException e2) {
			e2.printStackTrace();
		}
		dispose();
		strategy = null;
		img = null;
		screenImg = null;
		rect = null;
	}

	public static void main(String[] args) {
		new AWTFadout();
	}
}
Schaut richtig geil aus! ;-) *stolz bin*
Gruß Tom
 
Schaut zwar echt geil aus, aber ich bräucht was billiges , einen grafikeffekt, wie eine Explosion, mit ner abfolge von polygons oder so , alles was ich gemacht hab sieht nicht so toll aus
 
Zurück