Canvas globalAlpha 不影响图像?
我试图使用 putImageData() 将一系列图像放在画布上,但上下文的 globalAlpha 属性似乎没有效果。然而,它与drawImage()一起使用。这就是它应该如何工作的吗?
该片段不起作用:
cx.globalAlpha = 0.1;
cx.putImageData(imagesData[index], 0, 0);
I'm trying to put series of images on the canvas with putImageData(), but the globalAlpha property of the context doesn't seem to have an effect. However, it's working with drawImage(). Is that how it's supposed to work?
That snippet doesn't work:
cx.globalAlpha = 0.1;
cx.putImageData(imagesData[index], 0, 0);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,
putImageData
放置来自 imageData 的纯净、原始的像素,覆盖那里的任何像素。从规格来看:
No,
putImageData
places the pure, pristine pixels from the imageData, overwriting whatever pixel was there.From the spec:
您可以将图像作为图案,绘制路径并填充它。
You can make the image a pattern, draw a path and fill it.