Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pixel-perfect drawing in Cocoa on the retina display - just doing floor() won't work anymore

Historically, one has simply done a floor() after any calculations, to make sure all coordinates, heights and widths align properly to the pixel boundary.

However, this clearly won't work anymore on the retina display, because 0.5 point is now perfectly valid.

How should coders now code pixel perfect things to make their code properly support both standard and retina displays?

like image 788
NoobOverflow Avatar asked Dec 18 '25 03:12

NoobOverflow


1 Answers

Convert the rect to backing-aligned coordinates. You'll probably be doing this in the view, but windows can do it and screens can do it as well.

You may also need to convert back, since the release notes suggest that the backing coordinate spaces are in pixels, so those spaces will obviously be twice as big on a Retina display. If I had one, I'd test it. If everything looks twice as big when you use the backing coordinates in view space, that means you do need to convert them back to view coordinates.

like image 172
Peter Hosey Avatar answered Dec 20 '25 07:12

Peter Hosey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!