White Circles Black Circles

Actionscript:
  1. [SWF(backgroundColor=0xFFFFFF, width=500, height=500)]
  2.  
  3. var hsw:Number = stage.stageWidth / 2;
  4. var hsh:Number = stage.stageHeight / 2;
  5. var pointNum:int = 200;
  6. var points3D:Vector.<Number> = new Vector.<Number>();
  7. var points2D:Vector.<Number> = new Vector.<Number>();
  8. var uvts:Vector.<Number> = new Vector.<Number>();
  9. var sorted:Array = [];
  10. var thickness:Vector.<Number> = new Vector.<Number>();
  11. var radii:Vector.<Number> = new Vector.<Number>();
  12. var colors:Vector.<uint> = new Vector.<uint>();
  13.  
  14. var pnt:Point = new Point();
  15. var m:Matrix3D = new Matrix3D();
  16. var v:Vector3D = new Vector3D();
  17.  
  18. for (var i:int = 0; i<pointNum; i++){
  19.     v.x = Math.random()*1000-500;
  20.     m.identity();
  21.     m.appendRotation(Math.random()*360, Vector3D.X_AXIS);
  22.     m.appendRotation(Math.random()*360, Vector3D.Y_AXIS);
  23.     m.appendRotation(Math.random()*360, Vector3D.Z_AXIS);
  24.     v = m.transformVector(v);
  25.     points3D.push(v.x, v.y, v.z);
  26.     points2D.push(0,0);
  27.     uvts.push(0,0,0);
  28.     sorted.push({});
  29.     thickness.push(Math.random() * Math.random() * 50 + 4);
  30.     radii.push(Math.random() * 100 + 10);
  31.     colors.push([0xFFFFFF, 0x000000][int(Math.random()*2)]);
  32. }
  33. points3D.fixed = true;
  34. points2D.fixed = true;
  35. uvts.fixed = true;
  36. thickness.fixed = true;
  37. radii.fixed = true;
  38. colors.fixed = true;x
  39. var p:PerspectiveProjection = new PerspectiveProjection();
  40. var proj:Matrix3D = p.toMatrix3D();
  41. var dx:Number = 0, dy:Number = 0;
  42. addEventListener(Event.ENTER_FRAME, onLoop);
  43. function onLoop(evt:Event):void {
  44.     var i:int, j:int;
  45.     dx += (mouseX - dx) / 4;
  46.     dy += (mouseY - dy) / 4;
  47.     m.identity();
  48.     m.appendRotation(dx, Vector3D.Y_AXIS);
  49.     m.appendRotation(dy, Vector3D.X_AXIS);
  50.     m.appendTranslation(0, 0, 1000);
  51.     m.append(proj);
  52.     Utils3D.projectVectors(m, points3D, points2D, uvts);
  53.     for (i = 0, j = 0; i<points2D.length; i+=2, j++){
  54.         sorted[j].x = points2D[i] + hsw;
  55.         sorted[j].y = points2D[i + 1] + hsh;
  56.         sorted[j].z = uvts[j * 3 + 2];
  57.         sorted[j].color = colors[j];
  58.         sorted[j].radius = radii[j];
  59.         sorted[j].thickness = thickness[j];
  60.     }
  61.     sorted.sortOn("z", Array.NUMERIC);
  62.     graphics.clear();
  63.     for(i = 0; i<sorted.length; i++){
  64.         var element:Object = sorted[i];
  65.         var zpos:Number = element.z * 18000;
  66.         graphics.lineStyle(element.thickness, element.color);
  67.         graphics.drawCircle(element.x, element.y, zpos + element.radius);
  68.         graphics.endFill();
  69.     }
  70. }

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...


Have a look at the swf...


This entry was posted in Uncategorized and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*