+ 1
Which is faster canvas or div?
I have heard a lot of people say that moving div elements around is a lot faster than using a canvas. I have been developing games and I wanted to make sure this was true before continuing to use divs. Divs seem to be a lot easier to use since I can also use css to style them. I am using pure JavaScript and would like to know the differences in speed. I am currently using window.getAnimationFrame for my game . I need a way to use css to style my game objects.
3 Antworten
+ 2
Canvas is used as a container for graphics and Javascript is usually used with it.
So you should probably keep using your engine.
+ 1
<div> is a container like <article> and <canvas> is a 2d graphic creation tag like <svg>. <canvas> is the one that is usually used in games because of its specificities.
If you want more info on the topic you should take the HTML course (this will be covered in the HTML5 module).
+ 1
@lebi
I need a way to use css to style my game objects.
I have already built a full game engine using divs, so I dont know why I should turn back now. It's also much easier (and potentially faster) than canvas, I am using the window.requestAnimationFrame.
Can I use CSS to style objects in canvas or svg?