1
我一直試圖在畫布上繪製圖像,但未能如願。 HTML代碼只是簡單地創建畫布元素「canvas1」而不需要額外的處理。在HTML5的畫布上繪製圖像
這裏是JS:
function loadlogo(){
var logo = new Image();
var canvas = document.getElementById('canvas1');
var context = canvas.getContext('2d');
//resize the canvas to the current window
context.canvas.width = window.innerWidth;
context.canvas.height = window.innerHeight/3;
logo.src = "images/1.png";
logo.onload = function() {context.drawImage(logo,0,0;};
context.shadowOffsetX = 50;
context.shadowOffsetY = 30;
context.shadowColor = "pink";
}
window.addEventListener("load",loadlogo,false);
window.addEventListener("resize",loadlogo,false);
任何幫助,你可以給將是真棒! 我已經嘗試了很多方法,並且卡住了。
感謝, 布萊恩