INNER CODE UNIT · Rust
rect_in_bounds
autopilot-rs/autopy · src/bitmap.rs:133
fn rect_in_bounds(&self, rect: ((f64, f64), (f64, f64))) -> PyResult<bool> {
let rect = Rect::new(
Point::new((rect.0).0, (rect.0).1),
Size::new((rect.1).0, (rect.1).1),
);
Ok(self.bitmap.bounds().is_rect_visible(rect))
}
/// Open the image located at the path specified. The image's format is
/// determined from the path's file extension.
#[classmethod]
fn open(cls: &Bound<'_, PyType>, path: String) -> PyResult<Py<Bitmap>> {
let image = image::open(path).map_err(FromImageError::from)?;
let bmp = autopilot::bitmap::Bitmap::new(image, None);
let result = Py::new(cls.py(), Bitmap { bitmap: bmp })?;
Ok(result)
}