forked from: Gumowski Mira Pseudo-soundwave
/**
* Copyright Mohiniraj ( http://wonderfl.net/user/Mohiniraj )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qWQT
*/
// forked from shapevent's Gumowski Mira Pseudo-soundwave
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.text.*;
public class FlashTest extends Sprite {
public function FlashTest() {
var a:Number = 0.02;
var b:Number = .9998;
var xn1:Number = 5;
var yn1:Number = 2;
var xn:Number, yn:Number;
var scale:Number = 10;
var iterations:Number = 20000;
var step:Number = stage.stageWidth / iterations;
function f(x:Number):Number{
var x2:Number = x * x;
return a * x + (2 * (1 - a) * x2) / (1 + x2);
}
var canvas:BitmapData = Bitmap(addChild(new Bitmap(new BitmapData(500,500,false,0xEFEFEF)))).bitmapData;
var circle:Sprite = new Sprite();
with(circle.graphics) beginFill(0, 0.3), drawCircle(2,2,1);
var dot:BitmapData = new BitmapData(4,4,true, 0x000A0111);
dot.draw(circle);
var pnt:Point = new Point();
var txt:TextField = TextField(addChild(new TextField()));
txt.text = "move mouse";
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
canvas.fillRect(canvas.rect, 0xE54C10);
a = mouseY / 1000;
xn1 = mouseX / 30;
yn1 = 0;
for (var i:int = 0; i<iterations; i++){
xn = xn1;
yn = yn1;
xn1 = b * yn + f(xn);
yn1 = -xn + f(xn1);
pnt.x = i * step;
pnt.y = 250 + yn1 * scale;
canvas.copyPixels(dot, dot.rect, pnt, null, null, true);
}
}
}
}
}