summaryrefslogtreecommitdiff
path: root/webcam/webcam/effects/mirror/InverseMirrorEffect.as
blob: 8f0da4cf4640f39ed6241198c9065d0af7517416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * Neave Webcam // Inverse Mirror Effect
 * 
 * Copyright (C) 2008 Paul Neave
 * http://www.neave.com/
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation at http://www.gnu.org/licenses/gpl.html
 */

package com.neave.webcam.effects.mirror
{
	import flash.display.*;
	
	public class InverseMirrorEffect extends AbstractMirrorEffect
	{
		/**
		 * Creates a mirror effect where the top half of the image is inversed
		 * 
		 * @param	source			The source object to use for the effect
		 * @param	targetBitmap	The target bitmap data to draw the resulting effect into
		 */
		public function InverseMirrorEffect(source:IBitmapDrawable, targetBitmap:BitmapData)
		{
			super(source, targetBitmap, "Inverse Mirror");
			
			createMirror();
		}
		
		/**
		 * Sets up the mirror effect
		 */
		private function createMirror():void
		{
			mirrorMatrix.scale(-1, 1);
			mirrorMatrix.translate(rect.width, 0);
			mirrorBitmap = new BitmapData(rect.width, Math.round(rect.height / 2), false, 0xFF000000);
		}
	}
}