Snap to screen pixels instead of px

Fixes #7665.
This commit is contained in:
Matt Brubeck 2015-09-18 01:53:53 -07:00
parent 186ab5aa24
commit 9333f028e8
5 changed files with 133 additions and 80 deletions

View file

@ -236,6 +236,11 @@ impl Au {
((self.0 as f64) / (AU_PER_PX as f64)).round() as i32
}
#[inline]
pub fn to_nearest_pixel(self, pixels_per_px: f32) -> f32 {
((self.0 as f32) / (AU_PER_PX as f32) * pixels_per_px).round() / pixels_per_px
}
#[inline]
pub fn to_f32_px(self) -> f32 {
(self.0 as f32) / (AU_PER_PX as f32)