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

HAPPY 3.14??forked from: [QuickBox2D] addPolyを使って自由な形の物体を作る

http://twitter.com/9re/status/10427766979 によると
3/14のgoogleロゴはアルキメデスの外接・内接96角径らしく、
まったくイメージがつかないので書いてみる。
/**
 * Copyright Murai ( http://wonderfl.net/user/Murai )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ct1K
 */

//http://twitter.com/9re/status/10427766979 によると
//3/14のgoogleロゴはアルキメデスの外接・内接96角径らしく、
//まったくイメージがつかないので書いてみる。


// forked from paq's [QuickBox2D] addPolyを使って自由な形の物体を作る
package 
{
	import com.actionsnippet.qbox.QuickBox2D;
	import flash.display.Graphics;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.StageQuality;
	import flash.events.Event;

	[SWF(backgroundColor="0xFFFFFF", width=465, height=465, frameRate=60)]
	public class NintySixPolygon extends Sprite 
	{
		private var _qbox:QuickBox2D;
		
		
		//private const NINTY_SIX:int = 96;//最大頂点数ってきまってるのかな。91個以上だと表示消える。仕様?
		private const NINTY_SIX:int = 20;//重過ぎたからこのへんで。
		
		
		public function NintySixPolygon():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			//stage.quality = StageQuality.LOW;
			
			_qbox = new QuickBox2D(addChild(new MovieClip) as MovieClip,{ debug:false } );
			_qbox.createStageWalls();
			
			var i:int;
			var r:int = 3;
			var pol:Array;
			var verts:Array = new Array();
			var rad:Number = 360/NINTY_SIX * Math.PI / 180;
			for(i=0;i < NINTY_SIX;i++) {
				//dragきかないけどドキュメントと違う? http://actionsnippet.com/qb2d/docs/html/index.html
				pol=[0,0,r*Math.cos(rad*i),r*Math.sin(rad*i),r*Math.cos(rad*(i+1)),r*Math.sin(rad*(i+1))];
				_qbox.addPoly( { x:8, y:5, verts:[pol], draggable:true, lineAlpha: .1, fillColor:(0xff << 16 | (i/NINTY_SIX * 0xff)<<8 | (i/NINTY_SIX * 0xff))} );
				verts.push(pol);
			}

			
			//全部固まってる版。
			//_qbox.addPoly( { x:8, y:5,verts:verts, draggable:true, lineAlpha: .1, fillColor:(0xff << 16 | (i/NINTY_SIX * 0xff)<<8 | (i/NINTY_SIX * 0xff))} );
			
			_qbox.start();
			_qbox.mouseDrag();
		}	
	}
	
}