ipycanvas icon indicating copy to clipboard operation
ipycanvas copied to clipboard

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

Open ideoforms opened this issue 3 years ago • 3 comments

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.

ideoforms avatar Apr 21 '21 13:04 ideoforms

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

lucag avatar Dec 16 '22 17:12 lucag

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?)

martinRenou avatar Dec 19 '22 08:12 martinRenou

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

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

lucag avatar Jan 28 '23 18:01 lucag