View Javadoc

1   /*
2    * "Peko" Visual Novel System
3    *
4    * All Rights Reserved.
5    * Copyright (c) 1999-2003 Tsukuba Bunko.
6    *
7    * $Id: MofingEffect.java,v 1.1 2005/07/11 12:49:18 ppoi Exp $
8    */
9   package tsukuba_bunko.peko.canvas.stage.effect;
10  
11  import	java.awt.AlphaComposite;
12  import	java.awt.Graphics2D;
13  
14  import	java.awt.image.BufferedImage;
15  import	java.awt.image.ImageObserver;
16  
17  import	tsukuba_bunko.peko.canvas.stage.Effect;
18  
19  
20  /***
21   * "モーフィング" エフェクトです。
22   * @author	$Author: ppoi $
23   * @version	$Revision: 1.1 $
24   */
25  public class MofingEffect	extends Effect	{
26  
27  	/***
28  	 * alpha-composites
29  	 */
30  	private static AlphaComposite[]	_composites = new AlphaComposite[5];
31  	static	{
32  		_composites[4] = AlphaComposite.SrcOver;
33  		_composites[3] = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f );
34  		_composites[2] = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f );
35  		_composites[1] = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f );
36  		_composites[0] = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f );
37  	}
38  
39  
40  	/***
41  	 * <code>MofingEffect</code> のインスタンスを作成します。
42  	 */
43  	public MofingEffect()
44  	{
45  		super();
46  	}
47  
48  
49  	/***
50  	 * エフェクト名 "mofing" を取得します。
51  	 * @return	エフェクト名
52  	 */
53  	public String getName()
54  	{
55  		return "mofing";
56  	}
57  
58  
59  	/***
60  	 */
61  	protected void perform( BufferedImage screen, BufferedImage next )
62  	{
63  		ImageObserver	observer = getStageCanvas();
64  
65  		Graphics2D	g2 = screen.createGraphics();
66  		AlphaComposite[]	composites = _composites;
67  		int	size = composites.length;
68  		for( int i = 0; i < size; ++i )	{
69  			g2.setComposite( composites[i] );
70  			g2.drawImage( next, 0, 0, observer );
71  			drawImage( screen );
72  		}
73  	}
74  }