forked from: PerspectiveProjectionの練習 - 宇宙 -
forked from PerspectiveProjectionの練習 - 宇宙 - (diff: 49)
ActionScript3 source code
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/pj0u
*/
package
{
import flash.filters.BlurFilter;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.PerspectiveProjection;
public class FlashTest extends Sprite
{
public var _rootFOV:uint = new uint( root.transform.perspectiveProjection.fieldOfView );
public var bmp:Bitmap = new Bitmap();
public var blur:BlurFilter = new BlurFilter( 30,30,3 );
public function FlashTest()
{
stage.frameRate = 90
//ENTRY POINT:
this.x = stage.stageWidth/2;
this.y = stage.stageHeight/2;
this.z = 1000;
for( var i:int=0; i<20; i++ ) // for(var i:int = 0;i < 1000;i++)
{
var object:TestObject = new TestObject(this);
}
//bmp.bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, true, 0x000000); // Black on White Version
bmp.bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x000000); // White on Black Version
bmp.filters = [ blur ];
stage.addChildAt(bmp, 0);
bmp.bitmapData.draw(stage);
this.addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(event:Event):void
{
bmp.bitmapData.fillRect(bmp.bitmapData.rect, 0x000000);
bmp.bitmapData.draw(stage);
root.transform.perspectiveProjection.fieldOfView += 0.6; // 0.2;
if(root.transform.perspectiveProjection.fieldOfView > 100)
{
root.transform.perspectiveProjection.fieldOfView += 50;
}
if(root.transform.perspectiveProjection.fieldOfView < 100)
{
root.transform.perspectiveProjection.fieldOfView -= 50;
}
}
}
}
import flash.display.BlendMode;
import flash.display.DisplayObjectContainer;
import flash.display.Shape;
import flash.filters.BlurFilter;
class TestObject extends Shape
{
private var val :uint = 0xFFFFFF * Math.random(); // 0x0066FF; // 0xFFCCDD;
private var blur :BlurFilter = new BlurFilter( 40,40,3 );
public function TestObject(parent:DisplayObjectContainer)
{
this.blendMode = BlendMode.ADD;
this.filters = [ blur ];
this.graphics.beginFill( val );
this.graphics.drawCircle( 0,0,60 );
this.graphics.endFill();
this.x = ( Math.random()*1000) - 200;
this.y = ( Math.random()*1000) - 200;
this.z = ( -Math.random()*2000) - 200;
parent.addChild( this );
}
}