color-sampler icon indicating copy to clipboard operation
color-sampler copied to clipboard

Different pixel ratio devices bug

Open luchomatic opened this issue 8 years ago • 2 comments

Hi! I'm using your library for a project, and I noticed that there's a bug with devices which have a pixel ratio different from 1, I wrote a solution for this, how can I make a pull request?. Thanks.

luchomatic avatar Sep 07 '17 19:09 luchomatic

yes, please. how to reproduce? I will test.

emn178 avatar Sep 08 '17 04:09 emn178

Well I'm using fabric.JS in an angular project, the project is for a client so unfortunately I can't post any code. Anyway I wanted to create an eyedropper tool, I used your library to get the canvas pixel color, and it worked well in my computer, but whenever I try it in a device with a pixel ratio different than one, the color is not properly picked, it is like if the mouse is miss positioned. So what I did was to get the device pixel ratio and multiply the mouse event position in pixels with the user ratio. I've made a pull request with how I solved this and tested it in many screens and it worked, you're free to change it as you want and if you think it's a good solution you can merge it.

luchomatic avatar Sep 08 '17 13:09 luchomatic