Sometimes, we want to turn off antialiasing on an HTML canvas element with JavaScript.
In this article, we’ll look at how to turn off antialiasing on an HTML canvas element with JavaScript.
How to turn off antialiasing on an HTML canvas element with JavaScript?
To turn off antialiasing on an HTML canvas element with JavaScript, we can set context.imageSmoothingEnabled to false to turn off antialiasing for images.
For instance, we write
context.imageSmoothingEnabled = false;
to set the canvas’ context‘s imageSmoothingEnabled property to false to disable antialiasing on images in the canvas.
Conclusion
To turn off antialiasing on an HTML canvas element with JavaScript, we can set context.imageSmoothingEnabled to false to turn off antialiasing for images.