Expand description
Device-pixel ratios and logical-to-physical snapping helpers.
§Examples
use ailloli_ui_core::math::scale::{to_physical_f32, Scale};
assert_eq!(to_physical_f32(2.0, Scale::new(2.0)), 4.0);Device-pixel ratios and deterministic logical-to-physical snapping.
Structs§
- Physical
Rect I32 - Rectangle in physical pixel integers (snapped bounds).
- Scale
- Device pixel ratio (DPR) for logical ↔ physical conversion.
Functions§
- snap_
f32_ to_ physical_ px - Rounds a logical coordinate to the nearest physical integer pixel.
- snap_
point_ to_ physical - Snaps both coordinates of a logical point to physical integer pixels.
- snap_
rect_ to_ physical - Snaps both logical rectangle edges and derives a non-negative physical size.
- snap_
size_ to_ physical - Snaps logical width and height independently to physical integer pixels.
- to_
logical_ f32 - Converts physical pixels to logical units with
physical / dpr. - to_
physical_ f32 - Converts a logical length to physical pixels with
logical * dpr.