开发者

HTML5 Canvas replace to <div>

开发者 https://www.devze.com 2023-03-10 19:39 出处:网络
I\'m trying replace HTML5 C开发者_Python百科anvas to simple <div> But I don\'t know how to replace this line:

I'm trying replace HTML5 C开发者_Python百科anvas to simple <div> But I don't know how to replace this line:

ctx.drawImage(tileImg[drawTile],xpos,ypos);

Maybe anyone have idea how to replace this into <div>?

example : http://jsfiddle.net/HDpMW/5/ (this code from glacialflame.com)


Use <img> elements, and append them dynamically like this: http://jsfiddle.net/HDpMW/6/

var elem = document.createElement('img');
elem.src = tileDict[drawTile];
elem.style.position = 'absolute';
elem.style.left = xpos + 'px';
elem.style.top = ypos + 'px';
ctx.appendChild(elem);
0

精彩评论

暂无评论...
验证码 换一张
取 消