diff --git a/window/src/bitmaps/mod.rs b/window/src/bitmaps/mod.rs index 771edff61..75f20d835 100644 --- a/window/src/bitmaps/mod.rs +++ b/window/src/bitmaps/mod.rs @@ -115,10 +115,7 @@ pub trait BitmapImage { /// Draw a 1-pixel wide rectangle fn draw_rect(&mut self, rect: Rect, color: Color, operator: Operator) { - let bottom_right = Point { - x: rect.top_left.x + rect.width as isize, - y: rect.top_left.y + rect.height as isize, - }; + let bottom_right = rect.bottom_right(); // Draw the vertical lines down either side self.draw_line( diff --git a/window/src/lib.rs b/window/src/lib.rs index c8b5247fd..eaebef471 100644 --- a/window/src/lib.rs +++ b/window/src/lib.rs @@ -56,6 +56,16 @@ pub struct Rect { pub height: usize, } +impl Rect { + #[inline] + pub fn bottom_right(&self) -> Point { + Point { + x: self.top_left.x + self.width as isize, + y: self.top_left.y + self.height as isize, + } + } +} + pub trait PaintContext { fn get_dimensions(&self) -> Dimensions;