我正在使用 konvajs 在 Canvas 上绘图。我刚刚找到了一个不透明度属性,我可以在其中将整个形状(在我的例子中是一条闭合线)的不透明度设置为 alpha 值,但它还包括边框而不仅仅是填充不透明度。
new Konva.Line({
points: [30, 20, 49, 54, 100, 220],
fill: 'red', // put an opacity just on this color
stroke: 'black',
strokeWidth: 2,
closed : true,
opacity: 0.4
});
是否可以只使填充不透明并保持边界完全可见?
最佳答案
只需使用 rgba
进行填充:
new Konva.Line({
points: [30, 20, 49, 54, 100, 220],
fill: 'rgba(255,0,0,0.4)',
stroke: 'black',
strokeWidth: 2,
closed : true
});
关于javascript - 如何制作不透明的形状,而不是 konvajs 中的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42314501/