functiondraw() { var canvas = document.getElementById('tutorial'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); var img = new Image(); img.onload = function () { ctx.drawImage(img, 50,71,704,824,21,20,237,304);
} img.src="./avatar.png" } }
合成两张图片
1 2 3 4 5 6 7 8 9 10 11 12
functiondraw() { var canvas = document.getElementById('tutorial'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); var img = new Image(); img.onload = function () { ctx.drawImage(document.getElementById('bg'),-50,-50) ctx.drawImage(img, 50,71,704,824,21,20,237,304); } img.src="./avatar.png" } }