-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Rect): Rect manipulation methods
- Loading branch information
1 parent
3bda372
commit 893dd7a
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// Not used for now, might be used by `Rect::offset` later of removed | ||
#[derive(Debug, Default, Clone, Copy)] | ||
pub struct Offset { | ||
pub top: i32, | ||
pub right: i32, | ||
pub bottom: i32, | ||
pub left: i32, | ||
} | ||
|
||
impl Offset { | ||
pub fn topleft(top: i32, left: i32) -> Self { | ||
Self { | ||
top, | ||
right: 0, | ||
bottom: 0, | ||
left, | ||
} | ||
} | ||
} | ||
|
||
impl From<(i32, i32)> for Offset { | ||
fn from(value: (i32, i32)) -> Self { | ||
Self { | ||
top: value.0, | ||
right: value.1, | ||
bottom: value.0, | ||
left: value.1, | ||
} | ||
} | ||
} |