假设我有一个图像/site/image1.jpg将它绘制到画布上它会是这样的。
var image = new Image();
image.src = "/site/image1.jpg";
image.onload = function(){
context.drawImage(image,x,y);
}
假设我的互联网连接太慢,我怎么知道图片已经在画布上绘制了?
感谢。
答案 0 :(得分:1)
要进行锻炼,如果图像已被绘制,请保留标记或标记图像。
var image = new Image();
image.src = "blah.foo";
image.drawn = false; // Add a property to indicate if the image has been drawn
image.onload = function(){
ctx.drawImage(image,0,0);
image.drawn = true; // flag it as drawn
}
// then later you if you want to know if its been drawn
if(image.drawn){
console.log("Yes its been drawn.");
}