bhcli

"Strange's fork of n0tr1v's bhcli (onion)"
git clone https://git.dasho.dev/Strange/bhcli.git
Log | Files | Refs | README

commit b351efc72930c4c8292f2daabce32f04aa3545c0
parent f1b708b7c05603e1679607c52964210ff812abab
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 30 Mar 2023 02:40:31 -0700

cleanup

Diffstat:
Msrc/lechatphp/mod.rs | 16++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/lechatphp/mod.rs b/src/lechatphp/mod.rs @@ -480,17 +480,13 @@ fn has_red_in_center_area(letter_img: &DynamicImage) -> bool { // Count pixels that are On (either white or red) fn count_px_on(img: &DynamicImage) -> usize { - let mut count_on = 0; - for y in 0..14 { - for x in 0..8 { - if let Some(c) = get_pixel_in_bound(img, x, y) { - if c == *ON_COLOR || c == *RED_COLOR { - count_on += 1 - } - } + img.pixels().fold(0, |acc, (_, _, c)| { + if c == *ON_COLOR || c == *RED_COLOR { + acc + 1 + } else { + acc } - } - count_on + }) } // Count pixels that are red