flash on 2009-2-16
http://www.25lines.com/finalists/0812/034.txt
/* http://www.25lines.com/finalists/0812/034.txt */
package {
import flash.display.*;
import flash.geom.Point;
import flash.events.Event;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
map=new BitmapData(100,100,true,0xff000000);
addEventListener(Event.ENTER_FRAME,newPoint);
//addChild(new Bitmap(map));
}
private function newPoint(e:Event = null):void{
graphics.clear();
var k:uint=0;
if(arr.length<50&& Math.random()<.1) newPoint();
arr.push(new Point(Math.random()*stage.stageWidth,Math.random()*stage.stageHeight));
map.perlinNoise(40,40,3,6456,true,true,2|1,false,[new Point(px1+=.1,0),new Point(-px1/2,0),new Point(0,0)]);
for each(var c:Point in arr) {
graphics.moveTo(c.x,c.y);
var rgb24:uint=map.getPixel(c.x*.1,c.y*.1);
if(rgb24>0) {
c.x+=(128-(rgb24 >> 16))/5;
c.y+=(128-((rgb24 ^ (rgb24 >> 16 << 16)) >> 8))/5;
}
c.x+=(400-c.x)/50;
c.y+=(400-c.y)/50;
for each(var b:Point in arr)
if(b!=c && Point.distance(c,b)<30) {
var ang:Number=Math.atan2(c.y-b.y,c.x-b.x);
c.x+=((b.x+Math.cos(ang)*30)-c.x)/7;
c.y+=((b.y+Math.sin(ang)*30)-c.y)/7;
}
graphics.lineStyle(4,uint("0x0000"+uint(k+=1).toString(16)),1);
graphics.lineTo(c.x,c.y);
}
}
private var arr:Array=[];
private var px1:Number=0;
private var map:BitmapData;
}
}