diff options
author | 2020-04-29 03:23:08 +0200 | |
---|---|---|
committer | 2020-04-29 03:23:08 +0200 | |
commit | 475a2779a7a420ed6c1567a8dbc623114e2b7ec0 (patch) | |
tree | 725c5af5fe1ac835894641033daba4eb1cdd76c3 /core | |
parent | ec712c8032a25c5dc65152c3ab39bddaecbdce77 (diff) | |
download | iced-475a2779a7a420ed6c1567a8dbc623114e2b7ec0.tar.gz iced-475a2779a7a420ed6c1567a8dbc623114e2b7ec0.tar.bz2 iced-475a2779a7a420ed6c1567a8dbc623114e2b7ec0.zip |
Implement `Rectangle::with_size`
Diffstat (limited to 'core')
-rw-r--r-- | core/src/rectangle.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/src/rectangle.rs b/core/src/rectangle.rs index e8d0538a..6f953137 100644 --- a/core/src/rectangle.rs +++ b/core/src/rectangle.rs @@ -32,6 +32,20 @@ impl Rectangle<f32> { } } + /// Creates a new [`Rectangle`] with its top-left corner at the origin + /// and with the provided [`Size`]. + /// + /// [`Rectangle`]: struct.Rectangle.html + /// [`Size`]: struct.Size.html + pub fn with_size(size: Size) -> Self { + Self { + x: 0.0, + y: 0.0, + width: size.width, + height: size.height, + } + } + /// Returns the [`Point`] at the center of the [`Rectangle`]. /// /// [`Point`]: struct.Point.html |