📜  加载图像 js 上下文 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:14.102000             🧑  作者: Mango

代码示例1
function loadImage(url) {
  return new Promise(r => { let i = new Image(); i.onload = (() => r(i)); i.src = url; });
}

let img = await loadImage("./my/image/path.jpg");
ctx.drawImage(img, 0, 0);