E8 Inspired Forms

This doesn't have much to do with E8.. but it is vaguely inspired by it...

View the demo... (source code is below)

Actionscript:
  1. var hw:Number = stage.stageWidth / 2;
  2. var hh:Number = stage.stageHeight / 2;
  3.  
  4. var canvas:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight, false, 0x333333);
  5. addChild(new Bitmap(canvas));
  6. var vector:Shape = Shape(addChild(new Shape()));
  7.  
  8. // contrast
  9. var cm:ColorMatrixFilter = new ColorMatrixFilter([2.6,0,0,0,-101.6,0,2.6,0,0,-101.6,0,0,2.6,0,-101.6,0,0,0,1,0]);
  10. filters = [cm];
  11.  
  12. var over:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight, false, 0x333333);
  13. var frm:Bitmap = Bitmap(addChild(new Bitmap(over)));
  14.  
  15. frm.blendMode = BlendMode.OVERLAY;
  16.  
  17. var dotNum:int = 250;
  18. var dotConnected:int = 0;
  19. var curr:int = 0;
  20. var prevConnected:int = -1;
  21. var dots:Vector.<Point> = new Vector.<Point>(dotNum, true);
  22.  
  23. // consider altering this value manually
  24. var step:Number =  Math.random()*10
  25.  
  26. var theta:Number = -.5234;
  27. for (var i:int= 0; i <dotNum; i++){
  28.     var r:Number = 280
  29.     theta += step;
  30.     var xp:Number = hw + r  * Math.cos(theta);
  31.     var yp:Number = hh + r * Math.sin(theta);
  32.     dots[i] = new Point(xp, yp);
  33. }
  34.  
  35. var col:uint = 0xFFFFFF;
  36. var a:Point, b:Point;
  37. var connections:int = 0;
  38.  
  39. var txt:TextField = TextField(addChild(new TextField()));
  40. txt.defaultTextFormat = new TextFormat("_sans", 12);
  41. txt.textColor = 0x555555, txt.x = 10, txt.y = 10;
  42. txt.autoSize = "left";
  43. txt.text = step.toString();
  44.  
  45. addEventListener(Event.ENTER_FRAME, onLoop);
  46. function onLoop(evt:Event):void{
  47.      
  48.     over.applyFilter(canvas, over.rect, new Point(0,0), new BlurFilter(10,10, 1));
  49.    
  50.     for (var i:int = 0; i<100; i++){
  51.         if (dotConnected <dotNum - 1){
  52.             if (prevConnected != dotConnected){
  53.                 a = dots[dotConnected];
  54.             }
  55.             prevConnected = dotConnected;
  56.             b = dots[curr];
  57.             curr++;
  58.            
  59.             if (a != b){
  60.                 connections++;
  61.                 vector.graphics.clear();
  62.                 vector.graphics.lineStyle(0,col,0.05);
  63.                 vector.graphics.moveTo(a.x, a.y);
  64.                 vector.graphics.lineTo(b.x, b.y);
  65.                 canvas.draw(vector);
  66.             }
  67.             if (curr> dotNum - 1){
  68.                 curr = 0;
  69.                 dotConnected++;
  70.                 col =[0,0xFFFFFF][int(Math.random()*2)];
  71.             }
  72.         }else{
  73.             break;
  74.             trace("done");
  75.             removeEventListener(Event.ENTER_FRAME, onLoop);
  76.         }
  77.     }
  78. }

This entry was posted in BitmapData, Math, misc 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 *

*
*