-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
84 additions
and
25 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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod capture; | ||
mod utils; | ||
mod wayland_capture; | ||
mod xorg_capture; | ||
|
||
|
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,32 @@ | ||
pub(super) struct Rect { | ||
x: i32, | ||
y: i32, | ||
width: u32, | ||
height: u32, | ||
} | ||
|
||
impl Rect { | ||
// 计算两个矩形的交集面积 | ||
pub(super) fn new(x: i32, y: i32, width: u32, height: u32) -> Rect { | ||
Rect { | ||
x, | ||
y, | ||
width, | ||
height, | ||
} | ||
} | ||
|
||
// 计算两个矩形的交集面积 | ||
pub(super) fn overlap_area(&self, other_rect: Rect) -> i32 { | ||
let left = self.x.max(other_rect.x); | ||
let top = self.y.max(other_rect.y); | ||
let right = (self.x + self.width as i32).min(other_rect.x + other_rect.width as i32); | ||
let bottom = (self.y + self.height as i32).min(other_rect.y + other_rect.height as i32); | ||
|
||
// 与0比较,如果小于0则表示两个矩形无交集 | ||
let width = (right - left).max(0); | ||
let height = (bottom - top).max(0); | ||
|
||
width * height | ||
} | ||
} |
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