如何在FabricJS上缩放对象时停止控制边框填充增加?

时间:2016-03-10 10:34:23

标签: javascript canvas fabricjs

如何在FabricJS上缩放对象时停止控制边框填充增加?

我有一个矩形

canvas = new fabric.Canvas('c', {
                backgroundColor: '#FFFFFF'
});

// create a rectangle object
var rect = new fabric.Rect({
  left: 200,
  top: 185,
  fill: 'red',
  width: 100,
  height: 100,
  padding: 0
});

https://jsfiddle.net/wwexsh1f/2/

Scaled Rectangle Image

当我使用鼠标 rect.scaleTo 功能缩放矩形时,控件边框填充也会增加,尽管填充设置为 0

如何在缩放时停止填充增加?

1 个答案:

答案 0 :(得分:2)

设置strokeWidth = 0;

module HTTPResponseDecodeContentOverride
  def initialize(h,c,m)
    super(h,c,m)
    @decode_content = true
  end
  def body
    res = super
    if self['content-length']
      self['content-length']= res.bytesize
    end
    res
  end
end

module Net
  class HTTPResponse
    prepend HTTPResponseDecodeContentOverride
  end
end

它与对象一起缩放