Skip to main content

snap_to_device_pixels

Function snap_to_device_pixels 

Source
pub fn snap_to_device_pixels(
    origin: Vec2,
    size: Vec2,
    scale: f32,
) -> (Vec2, Vec2)
Expand description

Snap a box’s edges to the device pixel grid, as browsers do before painting backgrounds. Each edge rounds on its own, so two boxes that share an edge still share it after snapping: a scroll offset or a layout position with a fraction no longer leaves the antialiased seam between adjacent backgrounds through which whatever is behind them shows. A box with any width or height keeps at least one device pixel of it.