forked from: ためしに作ったもの
...
@author T.H.
/**
* Copyright makc3d ( http://wonderfl.net/user/makc3d )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cVKT
*/
// forked from 9dim's ためしに作ったもの
package {
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.display.Graphics;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
/**
* ...
* @author T.H.
*/
public class Main extends Sprite
{
private var sprite : Sprite = new Sprite();
private var graphic : Graphics = sprite.graphics;
private var X : int ;
private var Y : int;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
addChild(sprite);
var timer:Timer = new Timer(1 , 100000000); // 1ミリ秒 = 1回
var split:int = 0;
timer.addEventListener(TimerEvent.TIMER, timerFunc);
timer.start();
function timerFunc(event:TimerEvent):void
{
graphic.clear();
//背景の描画
graphic.beginFill(0x000000, 1);
graphic.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
graphic.lineStyle (1, 0x00FF00, 1.0); // 直線スタイルを設定
for (var i : int = 0; i < 9; i++) { //消失線の描画
graphic.moveTo (0, stage.stageHeight/9*i);
graphic.lineTo ((stage.stageWidth) / 2, (stage.stageHeight) / 2); // 線を描画
graphic.moveTo (stage.stageWidth, stage.stageHeight/9*i);
graphic.lineTo ((stage.stageWidth) / 2, (stage.stageHeight) / 2); // 線を描画
graphic.moveTo (stage.stageWidth/9*i,0);
graphic.lineTo ((stage.stageWidth) / 2, (stage.stageHeight) / 2); // 線を描画
graphic.moveTo (stage.stageWidth/9*i, stage.stageHeight);
graphic.lineTo ((stage.stageWidth) / 2, (stage.stageHeight) / 2); // 線を描画
}
graphic.beginFill(0x00FF00, 0);//塗りつぶしの設定
for (i = 0; i < 20; i++) { //奥行き感の表現
var F:Number = 345; // focal length
var Z:Number = F * (2 + i - split / 40); // distance
var S:Number = F / Z; // projection
X = stage.stageWidth * S;
Y = stage.stageHeight * S;
graphic.drawRect((stage.stageWidth-X)/2,(stage.stageHeight-Y)/2,X,Y);
}
if (split++ == 40) { split = 0; }
}
}
}
}