code: function(ctx) {
        if (!this.hasBorders) return;
  
        var MIN_SCALE_LIMIT = fabric.Object.MIN_SCALE_LIMIT,
            padding = this.padding,
            padding2 = padding * 2,
            strokeWidth = this.strokeWidth > 1 ? this.strokeWidth : 0;
  
        ctx.save();
  
        ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;
        ctx.strokeStyle = this.borderColor;
  
        var scaleX = 1 / (this.scaleX < MIN_SCALE_LIMIT ? MIN_SCALE_LIMIT : this.scaleX),
            scaleY = 1 / (this.scaleY < MIN_SCALE_LIMIT ? MIN_SCALE_LIMIT : this.scaleY);
  
        ctx.lineWidth = 1 / this.borderScaleFactor;
  
        ctx.scale(scaleX, scaleY);
  
        var w = this.getWidth(),
            h = this.getHeight();
  
        ctx.strokeRect(
          ~~(-(w / 2) - padding - strokeWidth / 2 * this.scaleX) + 0.5, // offset needed to make lines look sharper
          ~~(-(h / 2) - padding - strokeWidth / 2 * this.scaleY) + 0.5,
          ~~(w + padding2 + strokeWidth * this.scaleX),
          ~~(h + padding2 + strokeWidth * this.scaleY)
        );
  
        if (this.hasRotatingPoint && !this.lockRotation && this.hasControls) {
  
          var rotateHeight = (
            this.flipY
              ? h + (strokeWidth * this.scaleY) + (padding * 2)
              : -h - (strokeWidth * this.scaleY) - (padding * 2)
          ) / 2;
  
          var rotateWidth = (-w/2);
  
          ctx.beginPath();
          ctx.moveTo(0, rotateHeight);
          ctx.lineTo(0, rotateHeight + (this.flipY ? this.rotatingPointOffset : -this.rotatingPointOffset));
          ctx.closePath();
          ctx.stroke();
        }
  
        ctx.restore();
        return this;
      }
docs: Draws borders of an object's bounding box.
  Requires public properties: width, height
  Requires public options: padding, borderColor
  @method drawBorders
  @param {CanvasRenderingContext2D} ctx Context to draw on
  @return {fabric.Object} thisArg
  @chainable