Actionscript:
-
[SWF(backgroundColor=0xFFFFFF, width=500, height=500)]
-
-
var hsw:Number = stage.stageWidth / 2;
-
var hsh:Number = stage.stageHeight / 2;
-
var pointNum:int = 200;
-
var points3D:Vector.<Number> = new Vector.<Number>();
-
var points2D:Vector.<Number> = new Vector.<Number>();
-
var uvts:Vector.<Number> = new Vector.<Number>();
-
var sorted:Array = [];
-
var thickness:Vector.<Number> = new Vector.<Number>();
-
var radii:Vector.<Number> = new Vector.<Number>();
-
var colors:Vector.<uint> = new Vector.<uint>();
-
-
var pnt:Point = new Point();
-
var m:Matrix3D = new Matrix3D();
-
var v:Vector3D = new Vector3D();
-
-
for (var i:int = 0; i<pointNum; i++){
-
v.x = Math.random()*1000-500;
-
m.identity();
-
m.appendRotation(Math.random()*360, Vector3D.X_AXIS);
-
m.appendRotation(Math.random()*360, Vector3D.Y_AXIS);
-
m.appendRotation(Math.random()*360, Vector3D.Z_AXIS);
-
v = m.transformVector(v);
-
points3D.push(v.x, v.y, v.z);
-
points2D.push(0,0);
-
uvts.push(0,0,0);
-
sorted.push({});
-
thickness.push(Math.random() * Math.random() * 50 + 4);
-
radii.push(Math.random() * 100 + 10);
-
colors.push([0xFFFFFF, 0x000000][int(Math.random()*2)]);
-
}
-
points3D.fixed = true;
-
points2D.fixed = true;
-
uvts.fixed = true;
-
thickness.fixed = true;
-
radii.fixed = true;
-
colors.fixed = true;x
-
var p:PerspectiveProjection = new PerspectiveProjection();
-
var proj:Matrix3D = p.toMatrix3D();
-
var dx:Number = 0, dy:Number = 0;
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
function onLoop(evt:Event):void {
-
var i:int, j:int;
-
dx += (mouseX - dx) / 4;
-
dy += (mouseY - dy) / 4;
-
m.identity();
-
m.appendRotation(dx, Vector3D.Y_AXIS);
-
m.appendRotation(dy, Vector3D.X_AXIS);
-
m.appendTranslation(0, 0, 1000);
-
m.append(proj);
-
Utils3D.projectVectors(m, points3D, points2D, uvts);
-
for (i = 0, j = 0; i<points2D.length; i+=2, j++){
-
sorted[j].x = points2D[i] + hsw;
-
sorted[j].y = points2D[i + 1] + hsh;
-
sorted[j].z = uvts[j * 3 + 2];
-
sorted[j].color = colors[j];
-
sorted[j].radius = radii[j];
-
sorted[j].thickness = thickness[j];
-
}
-
sorted.sortOn("z", Array.NUMERIC);
-
graphics.clear();
-
for(i = 0; i<sorted.length; i++){
-
var element:Object = sorted[i];
-
var zpos:Number = element.z * 18000;
-
graphics.lineStyle(element.thickness, element.color);
-
graphics.drawCircle(element.x, element.y, zpos + element.radius);
-
graphics.endFill();
-
}
-
}
Was just looking at the stills from yesterdays post and noticing how much I actually like the way they looked. Really simple, just black and white cirlces - reminded me a bit of this flash experiment by Jared Tarbell (from 2002).
So I popped the same kind of black and white circles into the z-sorting 3D snippet I've been using recently and came up with this...