javascript Fabric.js - 带有笔划/边框的圆形上的透明背景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33785906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fabric.js - Transparent background on circle shape with stroke/border
提问by Simon
I have a circle being rendered in fabric.js version 1.6.0-rc.1:
我在 fabric.js 版本 1.6.0-rc.1 中渲染了一个圆圈:
var circlePatrol = new fabric.Circle({
top: 300,
left: 180,
radius: 200,
strokeDashArray: [10, 10],
stroke: 'black',
strokeWidth: 10,
fill: 'white',
opacity: 0.2
});
I want to set the background as transparent but retain the stroke around the circle. Is this possible in fabric.js? The opacity is also being applied to the stroke/border, I am trying to apply it to the background of the circle only.
我想将背景设置为透明,但保留圆圈周围的描边。这在fabric.js 中可能吗?不透明度也被应用于笔划/边框,我试图将它仅应用于圆圈的背景。
I have tried this as well with a transparent background, still no luck:
我也用透明背景试过这个,但仍然没有运气:
var circlePatrol = new fabric.Circle({
top: 300,
left: 180,
radius: 200,
strokeDashArray: [10, 10],
stroke: 'black',
strokeWidth: 10,
backgroundColor: 'transparent',
});
回答by Guy
回答by Dat Nguyen
Another option is to use 'transparent' value in fill
另一种选择是在填充中使用“透明”值
const rect = new fabric.Rect({
top: 10,
left: 10,
width: 50,
height: 50,
hasBorder: true,
stroke: 'yellow',
strokeWidth: 3,
fill:'transparent'
});