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

forked from: Doughnut with colorful smoke

お勉強中。。。ちょっとずつ変える。
/**
 * Copyright fakestar0826 ( http://wonderfl.net/user/fakestar0826 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/urPk
 */

// forked from yshu's Doughnut with colorful smoke
//お勉強中。。。ちょっとずつ変える。
package  
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.filters.BlurFilter;
	import flash.filters.ColorMatrixFilter;
	import flash.geom.Matrix3D;
	import flash.geom.Point;
	import flash.geom.Utils3D;
	import flash.geom.Vector3D;
	import flash.utils.getTimer;
	
	public class Doughnut extends Sprite
	{
		private var screen:BitmapData					= new BitmapData(475, 475, false, 0)
		private var vertices:Vector.<Number>			= new Vector.<Number>()
		private var uvtData:Vector.<Number>				= new Vector.<Number>()		
		private var matrix3D:Matrix3D 					= new Matrix3D()
		private var projectedVertices:Vector.<Number>	= new Vector.<Number>()
		
		private var max:Number = 3000
		private var r:Number = 175
			
		private var blurFilter:BlurFilter = new BlurFilter(3, 10, 3)
		private var colorMatrixFilter:ColorMatrixFilter = new ColorMatrixFilter([1.0789172123219,-0.1599448999802,0.0810276876583043,0,0,-0.0310251294027207,1.07137488688194,-0.0403497574792219,0,0,-0.124238196271341,-0.0166172810316758,1.14085547730302,0,0,0,0,0,1,0])
		
		private var point:Point = new Point()
		
		public function Doughnut() 
		{
			var a:Number
			var b:Number
			
			for (var c:Number = 0; c < max; c++ )
			{
				a = Math.PI * 2 * Math.random()
				b = Math.PI * 2 * Math.random()

				vertices.push
				(
					r*Math.sin(a)*Math.cos(b),
					r*Math.sin(a)*Math.sin(b),
					r*Math.cos(a)*Math.sin(a)
				)
			}

			addChild(new Bitmap(screen))
			
			stage.align = 'TL'
			stage.quality= 'LOW'
			stage.scaleMode = 'noScale'
			stage.addEventListener('enterFrame', render)
		}
		
		private function render(...e):void 
		{
			var t:Number = getTimer() / 10
			
			matrix3D = new Matrix3D()
			matrix3D.prependRotation( t*-1.2 ,	Vector3D.X_AXIS)
			matrix3D.prependRotation( t,	Vector3D.Y_AXIS)

			Utils3D.projectVectors(matrix3D, vertices, projectedVertices, uvtData)
			
			screen.lock()
			screen.applyFilter(screen, screen.rect, point, blurFilter )
			//残像の色
			//screen.applyFilter(screen, screen.rect, point, colorMatrixFilter)
			//残像のスクロール。スクロールさせると湯気っぽく見える。
			screen.scroll(0,-10)
			for (var c:Number = 0;c<projectedVertices.length-1; c+=2 ) screen.setPixel(projectedVertices[c] + 238, projectedVertices[c + 1] + 238, 0xff8800/*%max*cこの辺でドーナッツの色の設定*/)
			screen.unlock()
		}
	}
}