Fabric.js - stroke/border 圆形透明背景
Fabric.js - Transparent background on circle shape with stroke/border
我在 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
});
我想将背景设置为透明但保留圆圈周围的描边。这在 fabric.js 中可能吗?不透明度也应用于 stroke/border,我试图仅将其应用于圆圈的背景。
我也试过透明背景,还是不行:
var circlePatrol = new fabric.Circle({
top: 300,
left: 180,
radius: 200,
strokeDashArray: [10, 10],
stroke: 'black',
strokeWidth: 10,
backgroundColor: 'transparent',
});
您可以设置fill: 'rgba(0,0,0,0)'
。
var circlePatrol = new fabric.Circle({
top: 0,
left: 0,
radius: 200,
strokeDashArray: [10, 10],
stroke: 'black',
strokeWidth: 10,
fill: 'rgba(0,0,0,0)'
});
另一种选择是在填充
中使用'transparent'值
const rect = new fabric.Rect({
top: 10,
left: 10,
width: 50,
height: 50,
hasBorder: true,
stroke: 'yellow',
strokeWidth: 3,
fill:'transparent'
});
我在 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
});
我想将背景设置为透明但保留圆圈周围的描边。这在 fabric.js 中可能吗?不透明度也应用于 stroke/border,我试图仅将其应用于圆圈的背景。
我也试过透明背景,还是不行:
var circlePatrol = new fabric.Circle({
top: 300,
left: 180,
radius: 200,
strokeDashArray: [10, 10],
stroke: 'black',
strokeWidth: 10,
backgroundColor: 'transparent',
});
您可以设置fill: 'rgba(0,0,0,0)'
。
var circlePatrol = new fabric.Circle({
top: 0,
left: 0,
radius: 200,
strokeDashArray: [10, 10],
stroke: 'black',
strokeWidth: 10,
fill: 'rgba(0,0,0,0)'
});
另一种选择是在填充
中使用'transparent'值const rect = new fabric.Rect({
top: 10,
left: 10,
width: 50,
height: 50,
hasBorder: true,
stroke: 'yellow',
strokeWidth: 3,
fill:'transparent'
});