0

I'm trying replace HTML5 Canvas 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)

pimvdb
  • 151,816
  • 78
  • 307
  • 352
rhavd
  • 773
  • 2
  • 8
  • 9

1 Answers1

3

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);
pimvdb
  • 151,816
  • 78
  • 307
  • 352