diff options
author | 2020-04-28 04:39:59 +0200 | |
---|---|---|
committer | 2020-04-28 04:39:59 +0200 | |
commit | 5d5e60a5cc647b3227f78e1f3a3b31b2c27a3cc7 (patch) | |
tree | 8fb18cc3b9da5446ede5cc8478a307355efde877 /core | |
parent | fd1ceac3633c4f60852eb9f75da9fbb5e1f35df3 (diff) | |
download | iced-5d5e60a5cc647b3227f78e1f3a3b31b2c27a3cc7.tar.gz iced-5d5e60a5cc647b3227f78e1f3a3b31b2c27a3cc7.tar.bz2 iced-5d5e60a5cc647b3227f78e1f3a3b31b2c27a3cc7.zip |
Implement `Rectangle::new`
Diffstat (limited to 'core')
-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 |