diff --git a/src/geometry.rs b/src/geometry.rs index 5c645da..d45dbfd 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -77,7 +77,7 @@ impl PartialEq for Point { impl Eq for Point {} impl Rectangle { - fn from_corner_width_height(top_left: Point, width: u32, height: u32) -> Rectangle { + pub fn from_corner_width_height(top_left: Point, width: u32, height: u32) -> Rectangle { Rectangle { top_left, width, @@ -85,7 +85,7 @@ impl Rectangle { } } - fn from_corners(corner_a: Point, corner_b: Point) -> Rectangle { + pub fn from_corners(corner_a: Point, corner_b: Point) -> Rectangle { let left = corner_a.x().min(corner_b.x()); let top = corner_a.y().min(corner_b.y()); @@ -95,19 +95,19 @@ impl Rectangle { Rectangle::from_corner_width_height(Point::new(left, top), width, height) } - fn at_origin_with_size(width: u32, height: u32) -> Rectangle { + pub fn at_origin_with_size(width: u32, height: u32) -> Rectangle { Rectangle::from_corner_width_height(Point::origin(), width, height) } - fn width(&self) -> u32 { + pub fn width(&self) -> u32 { self.width } - fn height(&self) -> u32 { + pub fn height(&self) -> u32 { self.height } - fn with_width(&self, width: u32) -> Rectangle { + pub fn with_width(&self, width: u32) -> Rectangle { Rectangle { top_left: self.top_left, width, @@ -115,7 +115,7 @@ impl Rectangle { } } - fn with_height(&self, height: u32) -> Rectangle { + pub fn with_height(&self, height: u32) -> Rectangle { Rectangle { top_left: self.top_left, width: self.width, @@ -123,30 +123,30 @@ impl Rectangle { } } - fn top_left(&self) -> Point { + pub fn top_left(&self) -> Point { self.top_left } - fn top_right(&self) -> Point { + pub fn top_right(&self) -> Point { Point::new(self.top_left.x() + self.width, self.top_left.y()) } - fn bottom_right(&self) -> Point { + pub fn bottom_right(&self) -> Point { Point::new( self.top_left.x() + self.width, self.top_left.y() + self.height, ) } - fn bottom_left(&self) -> Point { + pub fn bottom_left(&self) -> Point { Point::new(self.top_left.x(), self.top_left.y() + self.height) } - fn area(&self) -> u32 { + pub fn area(&self) -> u32 { self.width * self.height } - fn intersects(&self, other: &Rectangle) -> bool { + pub fn intersects(&self, other: &Rectangle) -> bool { !(self.top_left().right_of(&other.top_right()) || self.top_left().below(&other.bottom_left()) || self.top_right().left_of(&other.top_left())