Module scale

Source
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§

PhysicalRectI32
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.