I'm making a game. Collisions in this game are based on color of pixel on canvas. I get color pixel and if it is for example red, player can't move. Unfortunately in firefox images are remotely blurred. Pixels are fluently changed from white color to red. But I don't want that. Any ideas how to answer to this problem?
相关问题
- Views base64 encoded blob in HTML with PHP
- How to get the background from multiple images by
- CV2 Image Error: error: (-215:Assertion failed) !s
- Does using percentages instead of pixels change an
- Replace image attributes for lazyload plugin on im
相关文章
- HTML5 control
- Use savefig in Python with string and iterative in
- Firefox remembering radio buttons incorrectly
- Where does this quality loss on Images come from?
- Specifying image dimensions in HTML vs CSS for pag
- How to insert pictures into each individual bar in
- How do I append metadata to an image in Matlab?
- Img url to dataurl using JavaScript
This is called anti-aliasing and is a result of interpolating the image when re-sized (or sub-pixeling shapes, text and so forth). It's something the browser do internally.
You can however turn off this in more recent version of the browser.
Here is a test I made to see if this works in your browser and the difference between the modes (as in the picture below) - the bottom version should not be smoothed:
ONLINE TEST
Add this snippet to your CSS style sheet (may or may not work depending on browser):
Update: The current form of the standard (with status "not ready for implementation") specify
crisp-edges
and notoptimize-contrast
as possible future standard. CSS class above is updated with this to reflect this for the non-prefixed value.- end update -
For webkit browsers you can disable image smoothing for the canvas element like this:
and for Mozilla:
(when this latter is available the CSS class is not necessary unless you scale the element itself which in any case should be avoided).