jupyter-widgets-contrib / ipycanvas

Interactive Canvas in Jupyter
https://ipycanvas.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
686 stars 64 forks source link

Use devicePixelRatio for improved rendering on Retina and other higher-density displays #191

Open ideoforms opened 3 years ago

ideoforms commented 3 years ago

On displays with a higher pixel density (e.g. MacBook Pro Retina displays), HTML canvas looks slightly fuzzy and pixellated by default.

Can be fixed by using the window's devicePixelRatio, and scale the context and canvas sizes accordingly - see example.

lucag commented 1 year ago

I've found exactly the same issue. Any progress?

martinRenou commented 1 year ago

You can create a canvas with more pixels than actually displayed on the screen:

canvas = Canvas(width=600, height=600, layout=dict(width='300px', height='300px'))

Accessing the devicePixelRatio is not possible, and it's unlikely that I'll implement this, as it does not quite make sense (what do you do when there are two clients connected? Which pixel ratio should be used?)

lucag commented 1 year ago

Hi — sorry for the late reply, and thank you for your comment.

Yes, the above works perfectly! Again, thank you!