代碼中包含的圖像未呈現在畫布上。如果我使用任何其他風景圖像,它會很好地工作。我究竟做錯了什麼?未在畫布上呈現的旋轉圖像
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var image = document.createElement("img");
image.onload = function(){
canvas.width = image.width;
canvas.height = image.height;
ctx.drawImage(image,0,0);
}
image.src = "http://org.school66.group.us.west.2.s3.amazonaws.com/church.jpg"
// this image works perfectly fine
// http://org.school66.group.us.west.2.s3.amazonaws.com/bookclub.jpg
<canvas id="canvas"></canvas><br>
<button id="clockwise">Rotate right</button>
<button id="counterclockwise">Rotate left</button>
兩者提供的圖像都在工作。 https://jsfiddle.net/93p5akp2/你的問題在哪裏? – Felix
我正在使用鉻,它不在那裏工作。我看到它在safari和ff中有效。我的主要瀏覽器是鉻...感謝Felix –
您是否設置了'canvas'元素的'height'和'width'? – Felix