In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

matrix transform point test

@see Please see, Zevan Rosser post @ http://actionsnippet.com/?p=1778
@author Mario Gonzalez
Get Adobe Flash player
by onedayitwillmake 18 Jul 2009
/**
 * Copyright onedayitwillmake ( http://wonderfl.net/user/onedayitwillmake )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/p6nQ
 */

package  
{
	import flash.display.CapsStyle;
	import flash.display.LineScaleMode;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.events.Event;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Point
	import frocessing.color.ColorHSV;
	
	/**
	 * @see Please see, Zevan Rosser post @ http://actionsnippet.com/?p=1778
	 * @author Mario Gonzalez
	 */
	[SWF(width =465, height = 465, frameRate=60, backgroundColor="#000000")]
	public class Matrixtransform extends Sprite
	{
		private var trans:Matrix = new Matrix();
		private var pnt:Point = new Point();
		private var hsv:ColorHSV = new ColorHSV(0, 1, 0.8);
		private var clones:Vector.<Shape> = new Vector.<Shape>;
		
		public function Matrixtransform() 
		{
			stage.scaleMode = 'noScale';
			stage.align = StageAlign.TOP_LEFT;
//			Wonderfl.delay(4);
			for (var i:int = 0; i < 8; i++)
			{
				hsv.h += 45;
				var color:ColorTransform = new ColorTransform();
					color.color = hsv.value;
				var clone:Shape = new Shape();
					clone.blendMode = "add";
					clones.push(clone)
					clone.rotation += 45 * i;
					clone.transform.colorTransform = color;
				addChild(clone);
			}
			
			x = stage.stageWidth / 2;
			y = stage.stageHeight / 2;
			addEventListener(Event.ENTER_FRAME, onLoop);
		}
		
		public function onLoop(evt:Event):void 
		{
			drawBase();
			var rotationAmount:Number = -1;
			var prevClone:Shape;
			for (var i:int = 0; i < clones.length; i++)
			{
				var clone:Shape = clones[i];
					clone.graphics.copyFrom(graphics);
					
			}
		}
		
		private function drawBase():void
		{
			
			graphics.clear();
			graphics.lineStyle(10, hsv.value, 1, false, LineScaleMode.NONE, CapsStyle.ROUND);
			pnt.x = 0;
			pnt.y = 0;
			trans.identity();
			trans.translate(20, 20);
			trans.scale(0.98, 0.98)
			trans.rotate(mouseX / 6 * Math.PI / 180);
			graphics.moveTo(pnt.x, pnt.y);
			for (var i:int = 0; i < 50; i++)
			{
				pnt = trans.transformPoint(pnt);
				graphics.lineTo(pnt.x, pnt.y);
			}
		}
	}
}