Skip to content

Instantly share code, notes, and snippets.

@mateuszkocz
Created July 19, 2013 19:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mateuszkocz/6041561 to your computer and use it in GitHub Desktop.
Save mateuszkocz/6041561 to your computer and use it in GitHub Desktop.
Disable image smoothing. Comes in handy when creating pixel-art game. The pixels will stay sharp.
/* You can aslo add */
canvas {
image-rendering: optimizeSpeed;
image-rendering: -moz-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
-ms-interpolation-mode: nearest-neighbor;
}
var context = canvas.getContext('2d');
context.webkitImageSmoothingEnabled = false;
context.mozImageSmoothingEnabled = false;
context.imageSmoothingEnabled = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment