commit 6bac75b4bdb3ae770fdbddc712278cf9deb7e7b7
parent 280c22237f16ec856fa2dec1ce39874b75da2809
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 30 Mar 2023 20:23:38 -0700
cleanup
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/lechatphp/mod.rs b/src/lechatphp/mod.rs
@@ -209,7 +209,7 @@ fn solve_difficulty3(img: &DynamicImage) -> Result<String, CaptchaErr> {
for dest in remaining.iter() {
let p1 = letter.center();
let p2 = dest.center();
- let red = Bresenham::new((p1.x as isize, p1.y as isize), (p2.x as isize, p2.y as isize))
+ let red = Bresenham::new(p1.into(), p2.into())
.filter(|(x, y)| img.get_pixel(*x as u32, *y as u32) == *RED_COLOR)
.count();
dest_count.insert(dest.clone(), red);
@@ -298,6 +298,12 @@ impl Point {
}
}
+impl From<Point> for bresenham::Point {
+ fn from(value: Point) -> Self {
+ (value.x as isize, value.y as isize)
+ }
+}
+
fn get_pixel_in_bound(img: &DynamicImage, x: u32, y: u32) -> Option<Rgba<u8>> {
if !img.in_bounds(x, y) {
return None;