flash on 2012-7-9
/**
* Copyright shapevent ( http://wonderfl.net/user/shapevent )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/4qFO
*/
package {
import flash.display.*;
import flash.events.*;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var a:Number = 0.02;
var b:Number = .9998;
var xn1:Number = 5;
var yn1:Number = 0;
var xn:Number, yn:Number;
var scale:Number = 10;
var iterations:Number = 20000;
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(600,600,false,0xEFEFEF)))).bitmapData;
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
canvas.fillRect(canvas.rect, 0xEFEFEF);
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);
canvas.setPixel( 230 + xn1 * scale, 250 + yn1 * scale, 0x000000);
}
}
}
}
}