Skip to content Skip to sidebar Skip to footer

Is Canvas Scaling More Performant Via Css Or Js?

The following document mentions some guidelines for performant scaling of HTML5 Canvas: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Optimizing_canvas#Scali

Solution 1:

Assuming you're not doing anything crazy, just set it to be the size you need. The performance difference will be negligible.

Solution 2:

By scaling in CSS you don't change your canvas "computed" size, which means, by scaling up, you'll lose displayed quality.

If you have to scale with CSS, try with JS to scale the actual size of the canvas to match, pixel per pixel, on user's screen.

Post a Comment for "Is Canvas Scaling More Performant Via Css Or Js?"