Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed May 30, 2024
1 parent 36b16de commit f6cf3e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cmdapp/src/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn should_key_image(img: &ColorImage) -> bool {

// Check for transparency at several scanlines
let threshold = ((img.width * 2) as f32 * KEYING_THRESHOLD) as usize;
let mut num_transparent_boundary_pixels = 0;
let mut num_transparent_pixels = 0;
let y_positions = [
0,
img.height / 4,
Expand All @@ -84,9 +84,9 @@ fn should_key_image(img: &ColorImage) -> bool {
for y in y_positions {
for x in 0..img.width {
if img.get_pixel(x, y).a == 0 {
num_transparent_boundary_pixels += 1;
num_transparent_pixels += 1;
}
if num_transparent_boundary_pixels >= threshold {
if num_transparent_pixels >= threshold {
return true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/conversion/color_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ impl ColorImageConverter {

// Check for transparency at several scanlines
let threshold = ((img.width * 2) as f32 * KEYING_THRESHOLD) as usize;
let mut num_transparent_boundary_pixels = 0;
let mut num_transparent_pixels = 0;
let y_positions = [0, img.height / 4, img.height / 2, 3 * img.height / 4, img.height - 1];
for y in y_positions {
for x in 0..img.width {
if img.get_pixel(x, y).a == 0 {
num_transparent_boundary_pixels += 1;
num_transparent_pixels += 1;
}
if num_transparent_boundary_pixels >= threshold {
if num_transparent_pixels >= threshold {
return true;
}
}
Expand Down

0 comments on commit f6cf3e8

Please sign in to comment.