show_image/
rectangle.rs

1/// A rectangle.
2#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
3pub struct Rectangle {
4	x: i32,
5	y: i32,
6	width: u32,
7	height: u32
8}
9
10impl Rectangle {
11	/// Create a rectangle from X, Y coordinates and the width and height.
12	pub fn from_xywh(x: i32, y: i32, width: u32, height: u32) -> Self {
13		Self { x, y, width, height }
14	}
15
16	/// Get the X location of the rectangle.
17	pub fn x(&self) -> i32 {
18		self.x
19	}
20
21	/// Get the Y location of the rectangle.
22	pub fn y(&self) -> i32 {
23		self.y
24	}
25
26	/// Get the width of the rectangle.
27	pub fn width(&self) -> u32 {
28		self.width
29	}
30
31	/// Get the height of the rectangle.
32	pub fn height(&self) -> u32 {
33		self.height
34	}
35}