diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/rectangle.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/src/rectangle.rs b/core/src/rectangle.rs index db8ebfc8..b9d0d5d2 100644 --- a/core/src/rectangle.rs +++ b/core/src/rectangle.rs @@ -17,6 +17,21 @@ pub struct Rectangle<T = f32> { } impl Rectangle<f32> { + /// Creates a new [`Rectangle`] with its top-left corner in the given + /// [`Point`] and with the provided [`Size`]. + /// + /// [`Rectangle`]: struct.Rectangle.html + /// [`Point`]: struct.Point.html + /// [`Size`]: struct.Size.html + pub fn new(top_left: Point, size: Size) -> Self { + Self { + x: top_left.x, + y: top_left.y, + width: size.width, + height: size.height, + } + } + /// Returns the [`Point`] at the center of the [`Rectangle`]. /// /// [`Point`]: struct.Point.html |