Skip to content

Instantly share code, notes, and snippets.

@linroex
Created March 12, 2017 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linroex/7611997463314c6fc34ca53c0dea8a9e to your computer and use it in GitHub Desktop.
Save linroex/7611997463314c6fc34ca53c0dea8a9e to your computer and use it in GitHub Desktop.
// 創造 img HTML 元素,並放入變數中
var bgImg = document.createElement("img");
// 設定這個元素的要顯示的圖片
bgImg.src = "images/map.png";
// 找出網頁中的 canvas 元素
var canvas = document.getElementById("game");
// 取得 2D繪圖用的物件
var ctx = canvas.getContext("2d");
function draw(){
ctx.drawImage(bgImg, 0, 0);
}
setTimeout(draw, 1000);
@godofhandsome
Copy link

thanks LOL

@shawnyin0226
Copy link

87 xd

@henryhihi
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment