【发布时间】:2020-04-21 15:33:33
【问题描述】:
我正在尝试在另一个充满颜色的图像上绘制透明图像。我有一个这样的代码结构,有一个基本图像,另一个透明的image_1 乘以它,然后image_2 应该被颜色填充和绘制。无法使用 fillStyle 和 fillRect 使其工作。
image_1.src = 'image_1_url';
image_1.onload = () => {
context.globalCompositeOperation = 'multiply';
context.drawImage(image_1, 0, 0, canvas.width, canvas.height);
image_2.src = 'image_2_url';
image_2.onload = () => {
//fill image_2 with a color and draw it on top of canvas
}
}
我应该按什么顺序使用颜色填充和 globalCompositeOperations?
【问题讨论】:
标签: javascript canvas html5-canvas