Function snap_rect_to_physical

Source
pub fn snap_rect_to_physical(rect: Rect, scale: Scale) -> PhysicalRectI32
Expand description

Snaps both logical rectangle edges and derives a non-negative physical size.

Snapping edges instead of width/height preserves their shared boundary. A reversed or collapsed result has zero physical width or height.

ยงExamples

use ailloli_ui_core::{PhysicalRectI32, Rect, Scale};
use ailloli_ui_core::math::snap_rect_to_physical;
assert_eq!(snap_rect_to_physical(Rect::new(1.0, 2.0, 3.0, 4.0), Scale::new(2.0)), PhysicalRectI32 { x: 2, y: 4, w: 6, h: 8 });