IT connecting Dots

by Admiral Potato

HTML

<script src="http://raw.github.com/AdmiralPotato/npos2d/master/src/vec2.js"></script>
<script src="http://raw.github.com/AdmiralPotato/npos2d/master/src/core.js"></script>
<script src="http://raw.github.com/AdmiralPotato/npos2d/master/src/font.js"></script>
<!DOCTYPE html>
<html>
    <body>
        
    </body>
</html>

CSS

body{
    background-color: #9df;
}

JavaScript

var n = NPos2d;
var s = new n.Scene({
    backgroundColor: 'transparent'
});
s.canvas.style.backgroundColor = 'transparent'; //temp hack

var DotAndLineHolder = function(){
    var t = this, requiredType = 'DotAndLineHolder';
    if(t.type !== requiredType){
        throw 'The ' + requiredType + ' Constructor must be invoked using the `new` keyword.';
    }
    t.dots = [];
    t.lines = [];
    s.add(t);
    return t;
};
DotAndLineHolder.prototype = {
    type: 'DotAndLineHolder',
    addDot: function (dot){
        this.dots.push(dot);
    },
    addLine: function (line){
        var t = this, prevLine;
        t.lines.push(line);
        if(t.lines.length > 1){
            prevLine = t.lines[t.lines.length -2];
            prevLine.addChild(line);
        }
    },
    update: function(){
        var t = this, i;
        for(i = 0; i < t.lines.length; i += 1){
            t.lines[i].update();
        }
        for(i = 0; i < t.dots.length; i += 1){
            t.dots[i].update();
        }
    }
};


var Dot = function(args){
    var t = this, requiredType = 'Dot';
    if(t.type !== requiredType){
        throw 'The ' + requiredType + ' Constructor must be invoked using the `new` keyword.';
    }
    args = args || {};
    t.args = args;
    t.pos = args.pos || new Vec2();
    if(!args.parent){throw 'Dots MUST have a parent DotAndLineHolder specified!';}
    t.parent = args.parent;
    t.parent.addDot(t);
    t.vel = new Vec2(Math.random(),0);
    return t;
};

Dot.prototype = {
    type: 'Dot',//only for constructor checking
    color: '#f33',
    strokeColor: '#999',
    radius: 5,
    numFrames: 100,
    render: function(){
        var t = this;
        s.drawCircle(t.pos,t.radius,t.color,true,2);
    },
    update: function(){
        var t = this;
        t.pos.add(t.vel);
        t.vel.rotate(deg);
        t.render();
    }
};


var Line = function(args){
    var t = this, requiredType = 'Line';
    if(t.type !== requiredType){
        throw 'The ' +...