我正在使用 html5 Canvas 库 Fabric js 绘制形状:
代码:
canvas.add(new fabric.Rect({top: 100,
左:100,
宽度:50,
高度:50,
填充:'空',
中风:'白色',
笔划宽度:1}));
但是它在我不想要的中间区域填充黑色。 我想要 html5 canvas 中的 strokeRect 之类的功能。 有什么建议吗?
最佳答案
使用transparent
而不是empty
来填充
矩形。
示例:
canvas.add(new fabric.Rect({top: 100,
left: 100,
width: 50,
height: 50,
fill: 'transparent',
stroke: 'white',
strokeWidth: 1
}));
关于javascript - 如何在 html5 Canvas 中绘制 Fabric js strokeRect?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33062976/