// Generated by CoffeeScript 1.6.3
(function() {
  var $;

  $ = jQuery;

  $.fn.extend({
    autoBackground: function(options) {
      var settings;
      settings = {
        location: "top-left",
        target: "body"
      };
      settings = $.extend(settings, options);
      this.load(function() {
        var canvas, context, pixel, x, y;
        canvas = document.createElement("canvas");
        context = canvas.getContext("2d");
        context.drawImage(this, 0, 0);
        switch (settings.location) {
          case "top-left":
            x = 0;
            y = 0;
            break;
          case "top-right":
            x = 0;
            y = this.width;
            break;
          case "bottom-left":
            x = this.height;
            y = 0;
            break;
          case "bottom-right":
            x = this.height;
            y = this.width;
        }
        pixel = context.getImageData(x, y, 1, 1).data;
        $(settings.target).css("background", "rgb(" + pixel[0] + "," + pixel[1] + "," + pixel[2] + ")");
        return true;
      });
      return true;
    }
  });

}).call(this);
