Fabric.js:如何删除填充和格式选择框? (缩放后仍然存在填充)

时间:2018-05-14 07:21:29

标签: fabricjs

我正在尝试将选择边框样式设置为在inkscape中显示(图像左侧)。 我试图将对象填充设置为零:

fabric.Object.prototype.set({
    padding: 0,
});

如果我放大,这更明显,填充增长。

示例:Left side inkscape selection box style, right side actual fabric.js selection box

如何删除填充?

这是jsFiddle

1 个答案:

答案 0 :(得分:2)

由于笔划宽度,将strokeWidth:0设置为对象。

<强> 样本

&#13;
&#13;
var canvas = window.__canvas = new fabric.Canvas('canvas');
 
var rect = new fabric.Rect({left: 10, top: 10,strokeWidth:0, width: 60, height: 60, fill: 'blue'});

rect.editable = true;
rect.customType = 'shape';
rect.describtion = 'fabric.js rect object';
rect.cornerColor = 'red';
rect.borderColor = 'red';
rect.cornerSize = 8;
rect.padding = 0;

canvas.add(rect);
canvas.setActiveObject(rect);
canvas.setZoom(20);
&#13;
canvas{
 border:2px solid #000;
}
&#13;
<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script>
<canvas id="canvas" width="400" height="400"></canvas> 
&#13;
&#13;
&#13;