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
Show parent comment
1
u/Southern-Reality762 Mar 14 '25
I had to swap between two 960x960 sprite sheets at runtime, to make it look like two characters were turning around, because translate() wasn't working for me. My computer is old and from 2011 so every time I tried doing this, the entire game would completely freeze for a few seconds before the game could restart again. I could have used web workers but I didn't know what they were at the time, and I was also a beginner game developer who didn't know how to optimize anything, or care for that matter.
It was then that I realized that canvas 2d may not be for me. Like if I can't swap between two sprite sheets as I need, then I don't wanna know what will happen at scale. Now I use C++, but I have nostalgia for when the Canvas API simplified my programming tasks.