ドラゴン曲線 ton forked:1favorite:4lines:48license : All rights reserved modified : 2008-12-24 09:55:04 Embed Tweet package { import flash.display.Sprite; import flash.events.Event; import flash.geom.Point; [SWF(frameRate=60, backgroundColor=0x000000)] public class DoragonCurve extends Sprite { private var list:Array = []; private const W:int = stage.stageWidth; private const H:int = stage.stageHeight; function DoragonCurve() { addLine(new Point(W/5, H/2), new Point(W-W/5, H/2)); stage.addEventListener(Event.ENTER_FRAME,onEnterFrameHandler); } private function onEnterFrameHandler(event:Event):void { var line:Line=list[0]; stage.removeChild(line); list.splice(0, 1); var p1:Point=new Point(); p1.x= line.distance/2 * Math.SQRT2 * Math.cos(line.angle-Math.PI/4) + line.startP.x; p1.y= line.distance/2 * Math.SQRT2 * Math.sin(line.angle-Math.PI/4) + line.startP.y; addLine(line.endP, p1); addLine(line.startP, p1); } private function addLine(p1:Point, p2:Point):void{ var line:Line = new Line(p1, p2); stage.addChild(line); list.push(line); } } } import flash.display.Shape; import flash.geom.Point; class Line extends Shape{ public var startP:Point; public var endP:Point; public var distance:Number; public var angle:Number; function Line(startP:Point, endP:Point) { this.startP = startP; this.endP = endP; distance = Point.distance(startP, endP); angle = Math.atan2(endP.y-startP.y, endP.x-startP.x); graphics.lineStyle(0,0xffffff); graphics.moveTo(startP.x, startP.y); graphics.lineTo(endP.x, endP.y); graphics.endFill(); } } Code Fullscreen Preview Fullscreen beta_chelsea.. h1ro web_shiino blackwater : 不断的画啊画啊 fractal Math.SQRT2 Point.distance addEventListener splice Math.atan2 Math.PI Shape push Math.cos Point Math.sin Event.ENTER_FRAME Array Event int Number sort new page view favorite forked pv0 forked from: ドラゴン曲線 hacker_4iwlb689 forked:0 favorite:0lines:48 (diff:1)