text: (function(global) {
    
    "use strict";
    
    var fabric = global.fabric || (global.fabric = { });
    
    if (fabric.Triangle) {
      fabric.warn('fabric.Triangle is already defined');
      return;
    }
    
    /** 
     * @class Triangle
     * @extends fabric.Object
     */
    fabric.Triangle = fabric.util.createClass(fabric.Object, /** @scope fabric.Triangle.prototype */ {
      
      /**
       * @property
       * @type String
       */
      type: 'triangle',
      
      /**
       * Constructor
       * @method initialize
       * @param options {Object} options object
       * @return {Object} thisArg
       */
      initialize: function(options) {
        options = options || { };
        
        this.callSuper('initialize', options);
        
        this.set('width', options.width || 100)
            .set('height', options.height || 100);
      },
      
      /**
       * @private
       * @method _render
       * @param ctx {CanvasRenderingContext2D} Context to render on
       */
      _render: function(ctx) {      
        var widthBy2 = this.width / 2,
            heightBy2 = this.height / 2;
        
        ctx.beginPath();
        ctx.moveTo(-widthBy2, heightBy2);
        ctx.lineTo(0, -heightBy2);
        ctx.lineTo(widthBy2, heightBy2);
        ctx.closePath();
        
        if (this.fill) {
          ctx.fill();
        }
        if (this.stroke) {
          ctx.stroke();
        }
      },
      
      /**
       * Returns complexity of an instance
       * @method complexity
       * @return {Number} complexity of this instance
       */
      complexity: function() {
        return 1;
      },
      
      /**
       * Returns svg representation of an instance
       * @method toSVG
       * @return {string} svg representation of an instance
       */
      toSVG: function() {
  
        var widthBy2 = this.width / 2,
            heightBy2 = this.height / 2;
  
        var points = [
          -widthBy2 + " " + heightBy2,
          "0 " + -heightBy2,
          widthBy2 + " " + heightBy2
        ].join(",");
  
        return '<polygon ' +
                'points="' + points + '" ' +
                'style="' + this.getSvgStyles() + '" ' +
                'transform="' + this.getSvgTransform() + '" ' +
                '/>';
      }
    });
    
    /**
     * Returns fabric.Triangle instance from an object representation
     * @static
     * @method Canvas.Trangle.fromObject
     * @param object {Object} object to create an instance from
     * @return {Object} instance of Canvas.Triangle
     */
    fabric.Triangle.fromObject = function(object) {
      return new fabric.Triangle(object);
    };
  
  })(typeof exports != 'undefined' ? exports : this);