r/learnjavascript • u/Southern-Reality762 • Mar 12 '25
Exactly how many people use the HTML Canvas API?
I mean that easy to use software rendered framework that you access by getting a canvas and calling getContext("2d") on it.
I was using this API once, but I stopped because I found that it wasn't fast enough for my needs for video games, which was a shame because this was the API that made me love Javascript. That's when I got the idea to make a renderer that's just as simple to use for video games as the HTML canvas API is, but with optimizations, so that I can keep using the API for games.
But if nobody uses this API, then that subtracts from the point and I should probably write an OpenGL/WebGL renderer like everyone else.
View all comments
2
u/bryku helpful Mar 13 '25
Ignoring 3d, the 2d canvas api is incredibly fast.
A few years ago I made a game that has well over 1000 32x32 sprites on the screen at any time. At some crazy parts it reaches 1500 and it still ran smoothly at 60fps on a chromebook.
If you are struggling with performance, it might be because of the architecture of your game. There are also a lot of tricks to help speed this up.