flash on 2009-10-18
...
@author Motoki Matsumoto
/**
* Copyright mtok ( http://wonderfl.net/user/mtok )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tT16
*/
package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
/**
* ...
* @author Motoki Matsumoto
*/
public class Curves extends Sprite
{
private var canvas:Sprite;
private var vecLen:Number = 50;
private var _dlta_th:Number = Math.PI / 100;
public function Curves()
{
addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
}
private function addedToStageHandler(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
addChild(canvas = new Sprite());
canvas.x = 465 * .5;
canvas.y = 465 * .5 - 100;
canvas.graphics.lineStyle(1, 0xff0000);
draw(canvas.graphics);
}
private function draw(g:Graphics):void {
var th:Number = 0, tmp:Number;
var limit:Number = 2 * Math.PI;
var cx:Number, cy:Number, ax:Number, ay:Number;
var cos:Function = Math.cos;
var sin:Function = Math.sin;
var r:Number;
var vfac:Number;
while (th < 2 * Math.PI) {
r = vecLen ;// + 20 * (Math.random() - 0.5);
vfac = 100 ;// + 10 * (Math.random() - 0.5);
tmp = th + 0.01 * (Math.random() - 0.5);
cx = r * cos(tmp);
cy = r * sin(tmp);
ax = cx * 3;
ay = vfac + (cy * 3);
g.moveTo(0, 0);
g.curveTo(cx, cy, ax, ay);
th += _dlta_th;
}
}
}
}