放物螺旋
r = a * sqrt(n);
/**
* Copyright cpu_t ( http://wonderfl.net/user/cpu_t )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sh8X
*/
// r = a * sqrt(n);
package {
import flash.display.*;
import flash.events.*;
[SWF(width = 400, height = 400, backgroundColor = 0x000000)]
public class FlashTest extends Sprite {
private const size:int = 400;
private var isStop:Boolean;
public function FlashTest() {
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
isStop = false;
stage.addEventListener(MouseEvent.MOUSE_DOWN, function(e:Event):void {
isStop = !isStop;
});
}
private var n:Number = 0;
private function enterFrameHandler(e:Event):void
{
if(!isStop){
var g:Graphics = this.graphics;
var x:Number = size / 2 + Math.cos(n / 180 * Math.PI) * Math.sqrt(n) * 2;
var y:Number = size / 2 + Math.sin(n / 180 * Math.PI) * Math.sqrt(n) * 2;
g.lineStyle(-1, 0x00FF00);
g.moveTo(x, y);
n+=3;
x = size / 2 + Math.cos(n / 180 * Math.PI) * Math.sqrt(n) * 2;
y = size / 2 + Math.sin(n / 180 * Math.PI) * Math.sqrt(n) * 2;
g.lineTo(x, y);
}
}
}
}