4 ms·
I think you could do both. Position 96x48px divs with css sprites over the canvas element to draw the images. I think this would be a performance win too, becau
by lars 17y ago
I think you could do both. Position 96x48px divs with css sprites over the canvas element to draw the images. I think this would be a performance win too, because browsers are already very good at drawing things like css sprites (although I don't know how well it combines with the canvas element).
- nostrademons 17y agoWhat would you end up drawing on the canvas, if the images are drawn with sprites? I can't think of anything else in Civilization that gets drawn, other than text for city names (which should probably be done as absolutely-positioned spans).
- wlievens 17y agoI think you can do sprites within canvas.
- nostrademons 17y agoYou can, but it's quite a bit slower. IIRC I benchmarked drawing a 32x32 image on canvas at about 15ms, while setting the top and left properties of an img tag or div with a background image was under 1 ms. The absolute numbers mean nothing (it was on an old laptop under Linux), but the ratios indicate at least an order of magnitude different in performance.
- roschdal 17y agoYou can use sprites within canvas, but excanvas doesn't support it. Therefore it will not work in Internet Explorer.