我不知道如何使 drawImage 工作......它什么都不做(除了它抛出一个带有未定义描述的异常):
layerCtx.globalAlpha = 0,2; // same thing with this line commented
layerCtx.drawImage(cvs, 0 , 0);
我有 2 个画布,一个是图层,另一个是用于使用鼠标绘制的。我想将用户在第一个画布上绘制的内容保存到图层并应用不透明度......我不会给你所有代码,但你必须知道以下代码有效:
layerCtx.putImageData(ctx.getImageData(0, 0, 800, 500), 0, 0);
但我不能将不透明度与前一个一起使用,因此正如在其他 stackoverflow.com 相关问题中所建议的那样,我想将 drawImage 与画布元素一起使用。
ctx是我的画布cvs的上下文,
layerCtx是我的画布层的上下文