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

Disable image smoothing on Raster? #1521

Closed
akeshavan opened this issue Sep 27, 2018 · 7 comments
Closed

Disable image smoothing on Raster? #1521

akeshavan opened this issue Sep 27, 2018 · 7 comments

Comments

@akeshavan
Copy link

I'm trying to disable image smoothing when zooming on a Raster, but I'm not able to. It looks like someone also asked this on stackoverflow but there are no replies. Does anyone have suggestions?

Description/Steps to reproduce

I'm trying to to set the imageSmoothingEnabled property of the canvas context to false so that the image looks pixelated, like in this example: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled which works on my browser (Google Chrome | 69.0.3497.100 (Official Build) (64-bit))

Link to reproduction test-case

Here is my codepen: https://codepen.io/akeshavan/pen/GYRZZm?editors=1010 with my attempt to do this with a paper.js Raster, but it doesn't work.

Any tips would be greatly appreciated. Thanks!

@sapics
Copy link
Member

sapics commented Sep 28, 2018

It would be necessary to get context from view.
Is it what you want? https://codepen.io/anon/pen/gBOMdJ?editors=1010

@akeshavan
Copy link
Author

Perfect! Thank you so much!

@lehni
Copy link
Member

lehni commented Sep 28, 2018

Let's keep this open as we should probably add an API for that?

What if we add a property to Raster called Raster.smoothing = true / false, defaulting to true to preserve current behavior? This would then control the smoothing behavior at the time of rendering the raster. That way, both styles could be used and mixed within one canvas.

@sasensi
Copy link
Contributor

sasensi commented Sep 30, 2018

@lehni, I implemented Raster.smoothing in #1529.

So, @akeshavan, once this change will be merged, you'll just have to do:

raster.smoothing = false;

@lehni
Copy link
Member

lehni commented Sep 30, 2018

@sasensi thanks for taking time to do this! I will make time to review it properly soon. There will some minor changes, mostly to align things with internal architecture and also change tracking to take note of the need for redraws, but nothing major.

@akeshavan
Copy link
Author

awesome, thanks @sasensi and @lehni !

@lehni lehni closed this as completed in 07ae09a Oct 3, 2018
lehni added a commit that referenced this issue Oct 3, 2018
…ng_property

Fix #1521 adding Raster.smoothing property
@lehni
Copy link
Member

lehni commented Oct 3, 2018

Thanks to @sasensi , this will be part of the next release! 🎉

Speaking of which: @sapics and @sasensi, could you help me with updating the CHANGELOG? You can look at its content to see how it should relate to the changes we've added since the last release.

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

No branches or pull requests

4 participants