function circles(a) 
{
    this.init(a);
}

circles.prototype =
{
    context: null,
    prevMouseX: null,
    prevMouseY: null,
    points: null,
    count: null,

    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        ctx.globalCompositeOperation = curr_composite_op;
    },

    init: function (ctx) 
    {
        this.context = ctx;
        this.initContext( ctx );
        this.points = new Array();
    },
    
    destroy: function () { },
    
    strokeStart: function (x, y) 
    {
        this.prevMouseX = x;
        this.prevMouseY = y;
    },
    
    stroke: function ( x, y ) 
    {
        this.points.push([x, y]);
        
        var l = x - this.prevMouseX;
        var k = y - this.prevMouseY;
        var h = Math.sqrt(l * l + k * k) * 2;
        var f = Math.floor(x / 100) * 100 + 50;
        var c = Math.floor(y / 100) * 100 + 50;
        var j = Math.floor(Math.random() * 10);
        var a = h / j;

        //this.context.strokeStyle = "rgba(0, 0, 0, 0.1)";
        this.context.strokeStyle = curr_color_str(0.1*curr_opacity);
        
        for (var g = 0; g < j; g++) 
        {
            this.context.beginPath();
            this.context.arc(f, c, (j - g) * a, 0, Math.PI * 2, true);
            this.context.stroke();
        }
        
        this.prevMouseX = x;
        this.prevMouseY = y;
    },
    
    strokeEnd: function (ctx, x, y) { }
};


function chrome(a) 
{
    this.init(a)
}

chrome.prototype =
{
    context: null,
    prevMouseX: null,
    prevMouseY: null,
    points: null,
    count: null,
    
    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        ctx.globalCompositeOperation = curr_composite_op;
        //if( darker_supported ) 
        //{
        //    this.context.globalCompositeOperation = "darker";
        //}
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
        this.points = new Array();
        this.count = 0;
    },
    
    destroy: function () { },
    
    strokeStart: function (x, y) 
    {
        this.prevMouseX = x;
        this.prevMouseY = y;
    },
    
    stroke: function (x, y) 
    {
        var b, a, g;
        this.points.push([x, y]);
        this.context.beginPath();
        this.context.moveTo(this.prevMouseX, this.prevMouseY);
        this.context.lineTo(x, y);
        this.context.stroke();
                
        for( var i = 0; i < this.points.length; i++ )
        {
            b = this.points[i][0] - this.points[this.count][0];
            a = this.points[i][1] - this.points[this.count][1];
            g = b * b + a * a;

            if (g < 1000) 
            {
                //this.context.strokeStyle = color_rnd_str( 0.1 );
                this.context.strokeStyle = color_rnd_str_verb( curr_color_r, curr_color_g, curr_color_b, 0.1*curr_opacity );
                
                this.context.beginPath(); 
                this.context.moveTo(this.points[this.count][0] + (b * 0.2), this.points[this.count][1] + (a * 0.2)); 
                this.context.lineTo(this.points[i][0] - (b * 0.2), this.points[i][1] - (a * 0.2)); 
                this.context.stroke()
            }
        }

        this.prevMouseX = x; 
        this.prevMouseY = y;
        this.count++;
    },

    strokeEnd: function (x, y) { }
};

function fur(a) 
{
    this.init(a)
}

fur.prototype =
{
    context: null,
    points: null,
    count: null,

    prevMouseX: null,
    prevMouseY: null,
    
    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        ctx.strokeStyle = curr_color_str(0.1*curr_opacity);
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
        this.points = new Array();
        this.count = 0;
    },

    destroy: function () { },
    
    strokeStart: function (x, y) 
    {
        this.prevMouseX = x;
        this.prevMouseY = y;
    },
    
    stroke: function (x, y) 
    {
        var b, a, g;
        this.points.push([x, y]);
        
        this.context.beginPath();
        this.context.moveTo(this.prevMouseX, this.prevMouseY);
        this.context.lineTo(x, y); 
        this.context.stroke();
        
        for( var i = 0; i < this.points.length; i++ ) 
        {
            b = this.points[i][0] - this.points[this.count][0];
            a = this.points[i][1] - this.points[this.count][1];
            g = b * b + a * a;
            
            if (g < 2000 && Math.random() > g / 2000) 
            {
                this.context.beginPath();
                this.context.moveTo(x + (b * 0.5), y + (a * 0.5));
                this.context.lineTo(x - (b * 0.5), y - (a * 0.5));
                this.context.stroke();
            }
        }
        
        this.prevMouseX = x;
        this.prevMouseY = y;
        this.count++;
    },

    strokeEnd: function (x, y) { }
};


function longfur(a) 
{
    this.init(a)
}

longfur.prototype =
{
    context: null,
    points: null,
    count: null,
    
    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        ctx.globalCompositeOperation = curr_composite_op;
        //ctx.strokeStyle = "rgba( 0, 0, 0, 0.05 )";
        ctx.strokeStyle = curr_color_str(0.05*curr_opacity);
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
        this.points = new Array();
        this.count = 0;
    },
    
    destroy: function () { },
    
    strokeStart: function (x, y) { },
    
    stroke: function (x, y) 
    {
        var e, b, a, h;
        this.points.push([x, y]);
        
        for( var i = 0; i < this.points.length; i++ ) 
        {
            e = -Math.random();
            b = this.points[i][0] - this.points[this.count][0];
            a = this.points[i][1] - this.points[this.count][1];
            h = b * b + a * a;

            if (h < 4000 && Math.random() > h / 4000) 
            {
                this.context.beginPath();
                this.context.moveTo(this.points[this.count][0] + (b * e), this.points[this.count][1] + (a * e));
                this.context.lineTo(this.points[i][0] - (b * e) + Math.random() * 2, this.points[i][1] - (a * e) + Math.random() * 2);
                this.context.stroke();
            }
        }
        
        this.count++;
    },
    
    strokeEnd: function (x, y) { }
};



function grid(a) 
{
    this.init(a)
}

grid.prototype =
{
    context: null,
    
    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        ctx.globalCompositeOperation = curr_composite_op;
        //if( darker_supported ) 
        //{
        //    ctx.globalCompositeOperation = "darker"
        //}
        //ctx.strokeStyle = "rgba( 0, 0, 0, 0.01 )"
        ctx.strokeStyle = curr_color_str(0.01*curr_opacity);
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
    },
    
    destroy: function () { },
    
    strokeStart: function (x, y) { },
    
    stroke: function (x, y) 
    {
        var a = Math.round(x / 100) * 100;
        var g = Math.round(y / 100) * 100;
        var c = (a - x) * 10;
        var b = (g - y) * 10;

        for( var e = 0; e < 50; e++ ) 
        {
            this.context.beginPath();
            this.context.moveTo(a, g);
            this.context.quadraticCurveTo(x + Math.random() * c, y + Math.random() * b, a, g);
            this.context.stroke()
        }
    },
    strokeEnd: function (x, y) { }
};


function ribbon(a) 
{
    this.init(a)
}

ribbon.prototype =
{
    context: null,
    mouseX: null,
    mouseY: null,
    painters: null,
    interval: null,
    
    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        //ctx.strokeStyle = "rgba( 0, 0, 0, 0.05 )";
        ctx.strokeStyle = curr_color_str(0.05*curr_opacity);
        ctx.globalCompositeOperation = curr_composite_op;        
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
        this.mouseX = SCREEN_WIDTH / 2; 
        this.mouseY = SCREEN_HEIGHT / 2;
        this.painters = new Array(); 
        
        for( var i = 0; i < 50; i++ ) 
        {
            this.painters.push( { dx: SCREEN_WIDTH / 2, dy: SCREEN_HEIGHT / 2, ax: 0, ay: 0, div: 0.1, ease: Math.random() * 0.2 + 0.6 } )
        }
        
        this.isDrawing = false;
        this.interval = setInterval( bargs(function (c) { c.update(); return false }, this), 1000 / 60 );
    },
    
    destroy: function () 
    {
        clearInterval(this.interval);
    },
    
    strokeStart: function (x, y) 
    {
        this.mouseX = x;
        this.mouseY = y;
        
        for (var i = 0; i < this.painters.length; i++) 
        {
            this.painters[i].dx = x;
            this.painters[i].dy = y;
        }
        this.shouldDraw = true;
    },

    stroke: function (x, y) 
    {
        this.mouseX = x;
        this.mouseY = y;
    },

    strokeEnd: function (x, y) { },
    
    update: function () 
    {
        for (var i = 0; i < this.painters.length; i++) 
        {
            var painter = this.painters[i];
            
            this.context.beginPath();
            this.context.moveTo( painter.dx, painter.dy );
            painter.dx -= painter.ax = (painter.ax + (painter.dx - this.mouseX) * painter.div) * painter.ease;
            painter.dy -= painter.ay = (painter.ay + (painter.dy - this.mouseY) * painter.div) * painter.ease;
            this.context.lineTo( painter.dx, painter.dy); 
            this.context.stroke();
        }
    }
};

function bargs(c) 
{
    var a = [];
    
    for (var b = 1; b < arguments.length; b++) 
    {
        a.push(arguments[b]);
    }

    return function () 
    {
        return c.apply(this, a)
    }
}


function shaded(a) 
{
    this.init(a)
}

shaded.prototype =
{
    context: null,
    prevMouseX: null,
    prevMouseY: null,
    points: null,
    count: null,
    
    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        ctx.globalCompositeOperation = curr_composite_op;
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
        this.points = new Array();
        this.count = 0;
    },

    destroy: function () { },
    
    strokeStart: function (x, y) 
    {
        this.prevMouseX = x;
        this.prevMouseY = y;
    },
    
    stroke: function (x, y) 
    {
        var b, a, g;
        this.points.push([x, y]);
        
        for (var i = 0; i < this.points.length; i++) 
        {
            b = this.points[i][0] - this.points[this.count][0];
            a = this.points[i][1] - this.points[this.count][1];
            g = b * b + a * a;

            if (g < 1000) 
            {
                //this.context.strokeStyle = "rgba(0, 0, 0, " + ((1 - (g / 1000)) * 0.1) + " )";
                var alpha = (1 - (g / 1000)) * 0.1;
                this.context.strokeStyle = curr_color_str(alpha*curr_opacity);
                this.context.beginPath();
                this.context.moveTo(this.points[this.count][0], this.points[this.count][1]);
                this.context.lineTo(this.points[i][0], this.points[i][1]);
                this.context.stroke();
            }
        }
        
        this.prevMouseX = x;
        this.prevMouseY = y;
        this.count++;
    },
    
    strokeEnd: function (b, a) { }
};

function sketchy(a) 
{
    this.init(a)
}

sketchy.prototype =
{
    context: null,
    prevMouseX: null,
    prevMouseY: null,
    points: null,
    count: null,
    
    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        //this.context.strokeStyle = "rgba(0, 0, 0, 0.05)";
        ctx.strokeStyle = curr_color_str( 0.05*curr_opacity );
        ctx.globalCompositeOperation = curr_composite_op;
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
        this.points = new Array(); this.count = 0
    },

    destroy: function () { },
    
    strokeStart: function (x, y) 
    {
        this.prevMouseX = x;
        this.prevMouseY = y;
    },
    
    stroke: function (x, y) 
    {
        var b, a, g;
        this.points.push([x, y]);
        
        this.context.strokeStyle = curr_color_str( 0.05*curr_opacity );

        this.context.beginPath();
        this.context.moveTo(this.prevMouseX, this.prevMouseY);
        this.context.lineTo(x, y);
        this.context.stroke();

        for( var i = 0; i < this.points.length; i++ ) 
        {
            b = this.points[i][0] - this.points[this.count][0];
            a = this.points[i][1] - this.points[this.count][1];
            g = b * b + a * a;
            
            if (g < 4000 && Math.random() > g / 2000)
            {
                this.context.beginPath();
                this.context.moveTo(this.points[this.count][0] + (b * 0.3), this.points[this.count][1] + (a * 0.3));
                this.context.lineTo(this.points[i][0] - (b * 0.3), this.points[i][1] - (a * 0.3));
                this.context.stroke();
            }
        }

        this.prevMouseX = x;
        this.prevMouseY = y;
        this.count++;
    },

    strokeEnd: function (x, y) { }
};


function squares(a) 
{
    this.init(a);
}

squares.prototype =
{
    context: null,
    prevMouseX: null,
    prevMouseY: null,
    
    initContext: function( ctx )
    {
        ctx.globalCompositeOperation = curr_composite_op;
        //this.context.strokeStyle = "rgba(0, 0, 0, 1)";
        //this.context.fillStyle = "rgba(255, 255, 255, 1)";
        ctx.strokeStyle = curr_color_str( curr_opacity );
        //this.context.fillStyle = curr_color_inv_str( curr_opacity );
        ctx.fillStyle = color_str( 255, 255, 255, curr_opacity );
        ctx.lineWidth = curr_line_width;
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
    },

    destroy: function () { },
    
    strokeStart: function (x, y) 
    {
        this.prevMouseX = x;
        this.prevMouseY = y;
    },

    stroke: function (x, y) 
    {
        var b = x - this.prevMouseX;
        var a = y - this.prevMouseY;
        var g = 1.57079633;
        var e = Math.cos(g) * b - Math.sin(g) * a;
        var c = Math.sin(g) * b + Math.cos(g) * a;
        
        this.context.beginPath();
        this.context.moveTo(this.prevMouseX - e, this.prevMouseY - c);
        this.context.lineTo(this.prevMouseX + e, this.prevMouseY + c);
        this.context.lineTo(x + e, y + c);
        this.context.lineTo(x - e, y - c);
        this.context.lineTo(this.prevMouseX - e, this.prevMouseY - c);
        this.context.fill();
        this.context.stroke();
        this.prevMouseX = x;
        this.prevMouseY = y;
    },

    strokeEnd: function (x, y) { }
};

function web(a) 
{
    this.init(a)
}

web.prototype =
{
    context: null,
    prevMouseX: null,
    prevMouseY: null,
    points: null,
    count: null,
    
    initContext: function( ctx )
    {
        ctx.lineWidth = curr_line_width;
        ctx.globalCompositeOperation = curr_composite_op;
        //ctx.strokeStyle = "rgba(0, 0, 0, 0.5)";
        ctx.strokeStyle = curr_color_str( 0.5*curr_opacity );
    },
    
    init: function (a) 
    {
        this.context = a;
        this.initContext( a );
        this.points = new Array();
        this.count = 0
    },
    
    destroy: function () { },
    
    strokeStart: function (x, y) 
    {
        this.prevMouseX = x;
        this.prevMouseY = y;
    },
    
    stroke: function (x, y) 
    {
        var b, a, g;
        this.points.push([x, y]);
        
        this.context.strokeStyle = curr_color_str( 0.5*curr_opacity );

        this.context.beginPath();
        this.context.moveTo(this.prevMouseX, this.prevMouseY); 
        this.context.lineTo(x, y);
        this.context.stroke();
        
        this.context.strokeStyle = curr_color_str( 0.1*curr_opacity );
        
        for (var i = 0; i < this.points.length; i++) 
        {
            b = this.points[i][0] - this.points[this.count][0];
            a = this.points[i][1] - this.points[this.count][1];
            g = b * b + a * a;
            
            if (g < 2500 && Math.random() > 0.9) 
            {
                this.context.beginPath();
                this.context.moveTo(this.points[this.count][0], this.points[this.count][1]);
                this.context.lineTo(this.points[i][0], this.points[i][1]);
                this.context.stroke();
            }
        }

        this.prevMouseX = x;
        this.prevMouseY = y;
        this.count++;
    },
    
    strokeEnd: function (x, y) { }
};


