aboutsummaryrefslogtreecommitdiff
path: root/src/math/rect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/rect.rs')
-rw-r--r--src/math/rect.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/math/rect.rs b/src/math/rect.rs
index 50c1cb0..6f993d1 100644
--- a/src/math/rect.rs
+++ b/src/math/rect.rs
@@ -1,3 +1,5 @@
+//! Rectangles where the sides are parallel to the x and y-axes.
+
use super::{LineSegment, Polygon, Surface, Vec2};
//use alga::general::{Additive, Identity};
use nalgebra::{ClosedAdd, ClosedSub, RealField, Scalar};
@@ -7,7 +9,7 @@ use serde::{Deserialize, Serialize};
use std::ops::{Add, AddAssign};
/// Represents a Rectangle with the value type T.
-#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Rect<T: Scalar + Copy> {
/// The x coordinate, or leftmost coordinate of the Rect.
pub x: T,
@@ -20,6 +22,8 @@ pub struct Rect<T: Scalar + Copy> {
}
impl<T: Scalar + Copy> Rect<T> {
+ /// Create a new Rectangle from the internal values, where it might be nicer to use a function
+ /// instead of setting the values directly.
pub fn new(x: T, y: T, w: T, h: T) -> Self {
Self { x, y, w, h }
}