PerspectiveProjectionの練習 - 宇宙 -
PerspectiveProjectionの練習
処理が遅いとか気にしない
/**
* Copyright geko ( http://wonderfl.net/user/geko )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/e9Nb
*/
// PerspectiveProjectionの練習
// 処理が遅いとか気にしない
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 bmp:Bitmap = new Bitmap();
public var blur:BlurFilter = new BlurFilter(4, 4, 3);
public function FlashTest() {
this.x = stage.stageWidth/2;
this.y = stage.stageHeight/2;
this.z = 1000;
for(var i:int = 0;i < 1000;i++){
var object:TestObject = new TestObject(this);
}
bmp.bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x000000);
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.2;
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 = 0xFFCCDD;
private var blur:BlurFilter = new BlurFilter(2, 2, 3);
public function TestObject(parent:DisplayObjectContainer){
this.blendMode = BlendMode.ADD;
this.filters = [blur];
this.graphics.beginFill(val);
this.graphics.drawCircle(0,0,3);
this.graphics.endFill();
this.x = Math.random()*1000-500;
this.y = Math.random()*1000-500;
this.z = -Math.random()*1000;
parent.addChild(this);
}
}