Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for image-rendering:pixelated on canvas element. #610

Closed
amadeus opened this issue Feb 11, 2016 · 2 comments
Closed

Support for image-rendering:pixelated on canvas element. #610

amadeus opened this issue Feb 11, 2016 · 2 comments

Comments

@amadeus
Copy link
Contributor

amadeus commented Feb 11, 2016

So Canvas 2d has support for .imageSmoothingEnabled = false, however in WebGL if we want nearest neighbor scaling we have to resort to internal WebGL functionality to accomplish it.

Chrome introduces a nice alternative solution to it, the CSS property image-rendering:pixelated.

It would be dope if we could apply this CSS prop to the canvas element before getting the context (at least) and have it apply to CSS transforms of the canvas element appropriately.

There are other values that can be applied to the image-rendering property so here's some info on the other acceptable values:

https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering

@phoboslab
Copy link
Owner

With the above commit, you can set the image-rendering style of the screen canvas at any time. This affects the up- and downscaling.

canvas.style.imageRendering = 'pixelated'; // Nearest neighbor scaling
canvas.style.imageRendering = 'auto'; // Linear scaling (default)

@amadeus
Copy link
Contributor Author

amadeus commented Feb 17, 2016

Oooh, fancy! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants