flash on 2009-4-25

by alpicola
♥0 | Line 39 | Modified 2009-04-25 23:32:39 | MIT License
play

ActionScript3 source code

/**
 * Copyright alpicola ( http://wonderfl.net/user/alpicola )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wYpj
 */

package {
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;

	[SWF(backgroundColor="#000000")]

	public class Test extends Sprite {

		public function Test() {
			var w:int = stage.stageWidth;
			var h:int = stage.stageHeight;
			var g:Graphics = graphics;
			var points:Vector.<Point> = new Vector.<Point>(4, true);
			var matrix:Matrix = new Matrix();
			var commands:Vector.<int> = new Vector.<int>(4, true);
			var data:Vector.<Number> = new Vector.<Number>(8, true);
			points[0] = new Point(0, 0);
			points[1] = new Point(1, 0);
			points[2] = new Point(1, 1);
			points[3] = new Point(0, 1);
			commands[0] = 1;
			commands[1] = 2;
			commands[2] = 2;
			commands[3] = 2;
			g.beginFill(0xffffff);
			for (var i:int = 0; i < 300; i++) {
				matrix.identity();
				matrix.scale(w * (Math.random() - 0.5), h * (Math.random() - 0.5));
				matrix.rotate(Math.PI * Math.random());
				matrix.translate(w * Math.random(), h * Math.random());
				for (var j:int = 0; j < 4; j++) {
					var p:Point = matrix.transformPoint(points[j]);
					data[j*2]   = p.x;
					data[j*2+1] = p.y;
				}
				g.drawPath(commands, data);
			}
			g.endFill();
		}

	}
}

Forked