diff options
Diffstat (limited to 'webcam/webcam/effects/mirror/AbstractMirrorEffect.as')
| -rwxr-xr-x | webcam/webcam/effects/mirror/AbstractMirrorEffect.as | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/webcam/webcam/effects/mirror/AbstractMirrorEffect.as b/webcam/webcam/effects/mirror/AbstractMirrorEffect.as new file mode 100755 index 0000000..57008f7 --- /dev/null +++ b/webcam/webcam/effects/mirror/AbstractMirrorEffect.as @@ -0,0 +1,68 @@ +/**
+ * Neave Webcam // Abstract 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.*;
+ import flash.geom.*;
+ import com.neave.webcam.effects.*;
+
+ internal class AbstractMirrorEffect extends AbstractEffect
+ {
+ protected var mirrorBitmap:BitmapData;
+ protected var mirrorMatrix:Matrix;
+ protected var mirrorPoint:Point;
+
+ /**
+ * An abstract mirror effect class, not to be instantiated
+ *
+ * @param source The source object to use for the effect
+ * @param targetBitmap The target bitmap data to draw the resulting effect into
+ * @param name The proper name of the effect
+ */
+ public function AbstractMirrorEffect(source:IBitmapDrawable, targetBitmap:BitmapData, name:String = "")
+ {
+ super(source, targetBitmap, name);
+
+ createAbstractMirror();
+ }
+
+ /**
+ * Sets up the mirror effect
+ */
+ private function createAbstractMirror():void
+ {
+ mirrorMatrix = new Matrix();
+ mirrorPoint = new Point();
+ }
+
+ /**
+ * Draws the mirror effect
+ */
+ override public function draw():void
+ {
+ super.draw();
+ mirrorBitmap.draw(sourceBitmap, mirrorMatrix);
+ targetBitmap.copyPixels(sourceBitmap, rect, point);
+ targetBitmap.copyPixels(mirrorBitmap, rect, mirrorPoint);
+ }
+
+ /**
+ * Removes the mirror effect and all other referenced objects
+ */
+ override public function destroy():void
+ {
+ super.destroy();
+ mirrorBitmap.dispose();
+ mirrorBitmap = null;
+ }
+ }
+}
\ No newline at end of file |
