gpt4 book ai didi

fabricjs - Fabric.js : How to remove padding and format selection box?(缩放后填充仍然存在)

转载 作者:行者123 更新时间:2023-12-05 04:06:05 34 4
gpt4 key购买 nike

我正在尝试将选择边框样式格式化为在 inkscape 中的外观(图像左侧)。我试图用这个将对象填充设置为零:

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

如果我放大,这会更明显并且填充会增加。

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

如何删除填充?

这里是 jsFiddle .

最佳答案

那是因为笔画宽度,设置strokeWidth:0为object。

演示

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);
canvas{
border:2px solid #000;
}
<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script>
<canvas id="canvas" width="400" height="400"></canvas>

关于fabricjs - Fabric.js : How to remove padding and format selection box?(缩放后填充仍然存在),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50324939/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com