gpt4 book ai didi

javascript - 如何制作不透明的形状,而不是 konvajs 中的边框

转载 作者:行者123 更新时间:2023-11-30 15:30:33 25 4
gpt4 key购买 nike

我正在使用 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/

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