0
我想通過添加一個名爲tint的畫布給畫布上的png着色,該畫布將顏色分配給主畫布上的png。但沒有什麼是繪製在所有:在畫布上着色png
JS
var tint = document.createElement('canvas');
tint.width = 20;
tint.height = 20;
var tintCtx = tintCanvas.getContext('2d');
var canvas = document.getElementById('canvasA');
var ctx = canvas.getContext('2d');
var pic = new Image();
pic.src = 'http://i3.minus.com/jUyvRw7sMVxJL.png';
var x =0;
var y=0;
tintCtx.fillStyle = #ff3633;
tintCtx.fillRect(x,y,20,20);
tintCtx.globalCompositeOperation = "destination-atop";
tintCtx.drawImage(pic, x, y);
ctx.drawImage(pic, x, y);
ctx.globalAlpha = 0.5;
ctx.drawImage(tint, x, y);