Skip to content

Commit 615b5ff

Browse files
committed
feat: return point and width as i32
1 parent fe68a5d commit 615b5ff

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Diff for: libwaysip/src/lib.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,29 @@ pub struct AreaInfo {
125125
}
126126

127127
impl AreaInfo {
128-
/// provide the width of the area
129-
pub fn width(&self) -> f64 {
128+
/// provide the width of the area as f64
129+
pub fn width_f64(&self) -> f64 {
130130
(self.end_x - self.start_x).abs()
131131
}
132132

133-
/// provide the height of the area
134-
pub fn height(&self) -> f64 {
133+
/// provide the width of the area as i32
134+
pub fn width(&self) -> i32 {
135+
self.width_f64() as i32
136+
}
137+
138+
/// provide the height of the area as f64
139+
pub fn height_f64(&self) -> f64 {
135140
(self.end_y - self.start_y).abs()
136141
}
137142

143+
/// provide the width of the area as i32
144+
pub fn height(&self) -> i32 {
145+
self.height_f64() as i32
146+
}
147+
138148
/// caculate the real start position
139-
pub fn left_top_point(&self) -> (f64, f64) {
140-
(self.start_x.min(self.end_x), (self.start_y.min(self.end_y)))
149+
pub fn left_top_point(&self) -> (i32, i32) {
150+
(self.start_x.min(self.end_x) as i32, (self.start_y.min(self.end_y)) as i32)
141151
}
142152
}
143153

0 commit comments

Comments
 (0)