Ok, here is my entry. I love perlins.
Preview here (I couldn’t think of a better place to host it, so DeviantArt it is!)
Click on it to activate the mouse as deviantArt haven’t heard about focusing to swfs. Then move the mouse to change the camera angle.
var bmd:BitmapData = new BitmapData(500,300,true, 0x00ffffff);
var bm:Bitmap = new Bitmap(bmd);
var pbmd1:BitmapData = new BitmapData(11,11,true,0x00ffffff);
var pbmd2:BitmapData = new BitmapData(11,11,true,0x00ffffff);
var perlins:BitmapData = new BitmapData(11,11,false,0x000000);
var p:Point = new Point(0,0);
var pr:Rectangle = new Rectangle(0,0,11,11);
var p1:Point = new Point(0,0);
var p2:Point = new Point(0,0);
var o1:Array = [p1];
var o2:Array = [p2];
var sourceCircle:Shape=new Shape();
addChild(bm);
sourceCircle.x = 50;
sourceCircle.y = 50;
//sourceCircle.graphics.lineStyle(1,0x000000);
sourceCircle.graphics.beginFill(0xffffff,1);
sourceCircle.graphics.drawCircle(0,0,10);
sourceCircle.graphics.endFill();
// initial camera angle
var hor:Number=20;
var ver:Number=70;
// camera depth
var fLen:Number=350;
// ooh heck, what an array!
var circles:Array = [
[-100, -100, 0],[-80, -100, 0],[-60, -100, 0],[-40, -100, 0],[-20, -100, 0],[0, -100, 0], [20, -100, 0],[40, -100, 0],[60, -100, 0],[80, -100, 0],[100, -100, 0],
[-100, -80, 0],[-80, -80, 0],[-60, -80, 0],[-40, -80, 0],[-20, -80, 0],[0, -80, 0], [20, -80, 0],[40, -80, 0],[60, -80, 0],[80, -80, 0],[100, -80, 0],
[-100, -60, 0],[-80, -60, 0],[-60, -60, 0],[-40, -60, 0],[-20, -60, 0],[0, -60, 0], [20, -60, 0],[40, -60, 0],[60, -60, 0],[80, -60, 0],[100, -60, 0],
[-100, -40, 0],[-80, -40, 0],[-60, -40, 0],[-40, -40, 0],[-20, -40, 0],[0, -40, 0], [20, -40, 0],[40, -40, 0],[60, -40, 0],[80, -40, 0],[100, -40, 0],
[-100, -20, 0],[-80, -20, 0],[-60, -20, 0],[-40, -20, 0],[-20, -20, 0],[0, -20, 0], [20, -20, 0],[40, -20, 0],[60, -20, 0],[80, -20, 0],[100, -20, 0],
[-100, 0, 0],[-80, 0, 0],[-60, 0, 0],[-40, 0, 0],[-20, 0, 0],[0, 0, 0], [20, 0, 0],[40, 0, 0],[60, 0, 0],[80, 0, 0],[100, 0, 0],
[-100, 20, 0],[-80, 20, 0],[-60, 20, 0],[-40, 20, 0],[-20, 20, 0],[0, 20, 0], [20, 20, 0],[40, 20, 0],[60, 20, 0],[80, 20, 0],[100, 20, 0],
[-100, 40, 0],[-80, 40, 0],[-60, 40, 0],[-40, 40, 0],[-20, 40, 0],[0, 40, 0], [20, 40, 0],[40, 40, 0],[60, 40, 0],[80, 40, 0],[100, 40, 0],
[-100, 60, 0],[-80, 60, 0],[-60, 60, 0],[-40, 60, 0],[-20, 60, 0],[0, 60, 0], [20, 60, 0],[40, 60, 0],[60, 60, 0],[80, 60, 0],[100, 60, 0],
[-100, 80, 0],[-80, 80, 0],[-60, 80, 0],[-40, 80, 0],[-20, 80, 0],[0, 80, 0], [20, 80, 0],[40, 80, 0],[60, 80, 0],[80, 80, 0],[100, 80, 0],
[-100, 100, 0],[-80, 100, 0],[-60, 100, 0],[-40, 100, 0],[-20, 100, 0],[0, 100, 0], [20, 100, 0],[40, 100, 0],[60, 100, 0],[80, 100, 0],[100, 100, 0]
];
var numCircles:int = circles.length;
addEventListener(Event.ENTER_FRAME, ef);
function ef(e:Event):void{
hor = 360 * mouseX /550;
ver = 180 * mouseY / 300;
p1.x += 0.2;
p2.y += 0.2;
pbmd1.perlinNoise(50,50,3,1,true,false,7,true,o1);
pbmd2.perlinNoise(50,50,3,7,true,false,7,true,o2);
perlins.fillRect(r, 0x00ffffff);
perlins.draw(pbmd1);
perlins.draw(pbmd2, null, null, BlendMode.SCREEN);
perlins.applyFilter(perlins, pr, p, pbf);
for (var q:int = 0; q < 11; q++)
{
for (var w:int = 0; w < 11; w++)
{
var color:int = perlins.getPixel(q,w);
var which:int = q * 11 + w;
circles[which][2] = -150 + 300 * color/16777215;
}
}
drawCircles(hor, ver);
}
var r:Rectangle = new Rectangle(0,0,500,300);
var cmf:ColorMatrixFilter = new ColorMatrixFilter([1,0,0,0,0,
0,1,0,0,0,
0,0,1,0,0,
0,0,0,0.9,0]);
var bf:BlurFilter = new BlurFilter(7,7,1);
var pbf:BlurFilter = new BlurFilter(7,7,1);
function drawCircles(hor:Number,ver:Number):void
{
bmd.applyFilter(bmd, r, new Point(0,0), cmf);
bmd.applyFilter(bmd, r, new Point(0,0), bf);
var vertsNewArray=[];
var distArray=[];
var dispArray=[];
var dist:Number;
hor=hor*Math.PI/180;
ver=ver*Math.PI/180;
for(var i:int=0;i<numCircles;i++){
vertsNewArray*=pointToCamera(circles*,hor,ver);
dist=Math.sqrt(Math.pow(fLen-vertsNewArray*[0],2)+Math.pow(vertsNewArray*[1],2)+Math.pow(vertsNewArray*[2],2));
distArray*=[dist,i];
}
distArray.sort(byDist);
for(var j:int=0;j < numCircles;j++){
var k:int = distArray[j][1];
dispArray[k]=[fLen/(fLen-vertsNewArray[k][0])*vertsNewArray[k][1],
-fLen/(fLen-vertsNewArray[k][0])*vertsNewArray[k][2]];
var cx:int = int (k/11);
var cy:int = k % 11;
var color:int = perlins.getPixel(cx, cy);
m.tx = dispArray[k][0] + 250;
m.ty = dispArray[k][1] + 150;
m.a = fLen/distArray[j][0];
m.d = fLen/distArray[j][0];
cf.redMultiplier = color/0xffffff;
cf.greenMultiplier = color/0xffffff;
cf.blueMultiplier = color/0xffffff;
bmd.draw(sourceCircle,m,cf);
}
}
var m:Matrix = new Matrix(1,0,0,1,0,0);
var cf:ColorTransform = new ColorTransform(1,1,1,1);
function byDist(v:Array,w:Array):Number {
if (v[0] > w[0]){
return -1;
} else if (v[0] < w[0]){
return 1;
} else {
return 0;
}
}
function pointToCamera(v:Array,t:Number,p:Number):Array {
var newCoords:Array=[];
newCoords[0]=v[0]*Math.cos(t)*Math.sin(p)+v[1]*Math.sin(t)*Math.sin(p)+v[2]*Math.cos(p);
newCoords[1]=-v[0]*Math.sin(t)+v[1]*Math.cos(t);
newCoords[2]=-v[0]*Math.cos(t)*Math.cos(p)-v[1]*Math.sin(t)*Math.cos(p)+v[2]*Math.sin(p);
return newCoords;
}