Author Archives: Zevan

Connect The Dots E8

CLICK HERE TO COPY
Actionscript:

[SWF(width = 500, height = 500)]

const TWO_PI:Number = Math.PI * 2;

var centerX:Number = stage.stageWidth / 2;

var centerY:Number = stage.stageHeight / 2;

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void{

    // data

    var points:Array = [];

    var i:int = 0;

    var pointNum : int = Math.max(2,int(mouseX / 12))

   

    var radius:Number = 200;

  [...]

Posted in Graphics, Math, misc | Tagged , , | 4 Comments

Nonsense Clocks

CLICK HERE TO COPY
Actionscript:

[SWF(width = 500, height=500, backgroundColor=0x000000)]

 

var clockNum:int = 100;

var clocks:Vector.<Function> = new Vector.<Function>(clockNum, true);

 

var clockContainer:Sprite = Sprite(addChild(new Sprite()));

clockContainer.x = stage.stageWidth / 2;

clockContainer.y = stage.stageHeight / 2;

buildClocks();

runClocks();

 

function buildClocks():void{

    for (var i:int = 0; i<clockNum; i++){

        var theta:Number = Math.random() * Math.PI * 2;

        var radius:Number = Math.random() [...]

Posted in 3D, Graphics, misc, motion | Tagged , , | 3 Comments

Clock Quiz

Here is a quick sunday quiz. Create some kind of clock with as little code as possible. Even just a textfield and the date object would cut it, but preferably try to do something a little more interesting. Post your results in the comments. I'll post my version on monday EOD.
[EDIT: my clock can be [...]

Posted in Quiz | Tagged , , , | 19 Comments

Haskell Inspired zipWith() Function

CLICK HERE TO COPY
Actionscript:

initOperators();

 

trace(zipWith("-", [1,2,3], [1,2,3]));

trace(zipWith("+", [1,2,3], [1,2,3]));

trace(zipWith("*", [1,2,3], [1,2,3]));

trace(zipWith("+", [1,1,1,3], [4,5,6,7]));

trace(zipWith("<<", [2, 4], [1,1]));

/*

outputs:

 

0,0,0

2,4,6

1,4,9

5,6,7,10

4,8

*/

 

function zipWith(op:String, a:Array, b:Array):Array{

    var aLeng:int = a.length;

    var bLeng:int = b.length;

    var leng:Number = (aLeng <bLeng) ? aLeng : bLeng;

    var zipped:Array = [];

   

    if (!this[op])return [];

   

    for (var i:int = 0; [...]

Posted in Number, Operators, arrays, binary, functions, misc, return values | Tagged , , , | 2 Comments