function hroms( context )
{
  this.init( context );
}

hroms.prototype =
{
  context: null,

  prevMouseX: null, prevMouseY: null,

  points: null, count: null,

  init: function( context )
  {
    this.context = context;

    if (RegExp(" AppleWebKit/").test(navigator.userAgent))
      this.context.globalCompositeOperation = 'darker';

    this.points = new Array();
    this.count = 0;
  },

  destroy: function()
  {
  },

  strokeStart: function( mouseX, mouseY )
  {
    this.prevMouseX = mouseX;
    this.prevMouseY = mouseY;
  },

  stroke: function( mouseX, mouseY )
  {
    var i, dx, dy, d;

    this.points.push( [ mouseX, mouseY ] );

    this.context.lineWidth = BRUSH_SIZE;
    this.context.strokeStyle = "rgba(" + COLOR[0] + ", " + COLOR[1] + ", " + COLOR[2] + ", " + 0.1 * BRUSH_PRESSURE + ")";
    this.context.beginPath();
    this.context.moveTo(this.prevMouseX, this.prevMouseY);
    this.context.lineTo(mouseX, mouseY);
    this.context.stroke();

    for (i = 0; i < this.points.length; i++)
    {
      dx = this.points[i][0] - this.points[this.count][0];
      dy = this.points[i][1] - this.points[this.count][1];
      d = dx * dx + dy * dy;

      if (d < 1000)
      {
        this.context.strokeStyle = "rgba(" + Math.floor(Math.random() * COLOR[0]) + ", " + Math.floor(Math.random() * COLOR[1]) + ", " + Math.floor(Math.random() * COLOR[2]) + ", " + 0.1 * BRUSH_PRESSURE + " )";
        this.context.beginPath();
        this.context.moveTo( this.points[this.count][0] + (dx * 0.2), this.points[this.count][1] + (dy * 0.2));
        this.context.lineTo( this.points[i][0] - (dx * 0.2), this.points[i][1] - (dy * 0.2));
        this.context.stroke();
      }
    }

    this.prevMouseX = mouseX;
    this.prevMouseY = mouseY;

    this.count ++;
  },

  strokeEnd: function()
  {

  }
}
