Rename Rectangle::round to snap

Also use `ceil` instead of `round`.
Closes #380.
This commit is contained in:
Héctor Ramón Jiménez 2020-06-02 04:38:55 +02:00
parent b96d87ff69
commit 94af348846
5 changed files with 8 additions and 9 deletions

View file

@ -126,15 +126,15 @@ impl Rectangle<f32> {
}
}
/// Rounds the [`Rectangle`] to __unsigned__ integer coordinates.
/// Snaps the [`Rectangle`] to __unsigned__ integer coordinates.
///
/// [`Rectangle`]: struct.Rectangle.html
pub fn round(self) -> Rectangle<u32> {
pub fn snap(self) -> Rectangle<u32> {
Rectangle {
x: self.x as u32,
y: self.y as u32,
width: (self.width + 0.5).round() as u32,
height: (self.height + 0.5).round() as u32,
width: self.width.ceil() as u32,
height: self.height.ceil() as u32,
}
}
}