Skip to content

Commit

Permalink
feat: return point and width as i32
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Dec 19, 2023
1 parent fe68a5d commit 615b5ff
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions libwaysip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,29 @@ pub struct AreaInfo {
}

impl AreaInfo {
/// provide the width of the area
pub fn width(&self) -> f64 {
/// provide the width of the area as f64
pub fn width_f64(&self) -> f64 {
(self.end_x - self.start_x).abs()
}

/// provide the height of the area
pub fn height(&self) -> f64 {
/// provide the width of the area as i32
pub fn width(&self) -> i32 {
self.width_f64() as i32
}

/// provide the height of the area as f64
pub fn height_f64(&self) -> f64 {
(self.end_y - self.start_y).abs()
}

/// provide the width of the area as i32
pub fn height(&self) -> i32 {
self.height_f64() as i32
}

/// caculate the real start position
pub fn left_top_point(&self) -> (f64, f64) {
(self.start_x.min(self.end_x), (self.start_y.min(self.end_y)))
pub fn left_top_point(&self) -> (i32, i32) {
(self.start_x.min(self.end_x) as i32, (self.start_y.min(self.end_y)) as i32)
}
}

Expand Down

0 comments on commit 615b5ff

Please sign in to comment.