About perfomance

I’m working on a html canvas. I’m curious for particles, a character, or static object on the canvas.
In which case would the performance be better if I load in an image (e.g. as a playable character, square) or draw the character like:

ctx.beginPath();
ctx.lineWidth = “6”;
ctx.strokeStyle = “red”;
ctx.rect(5, 5, 290, 140);
ctx.stroke();

When is it faster (or not) to load in images/pictures or to create something on a canvas yourself? I’m curious about the performance aspect. Both moving/transforming or a static object.

Hi @Evan and welcome to the community :wave:

Personally, I don’t have much experience with canvas. If no experienced canvas user answers, I would recommend doing your own performance tests by creating a large amount of each type of entity and measure the time for certain operations. This way you could also create a test case which closely resembles your actual use case.

Sorry for not being able to give you more specific advice. :upside_down_face:

Have a nice day,
Michael