Skip to content

Commit

Permalink
fix: custom antialiasing artifacts (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowinston authored Nov 3, 2023
1 parent a1f066f commit 0f25654
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions catwalk/src/mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ impl RoundMask {
for diff in diffs {
if diff <= self.aa_level.pow(2) {
// Fraction of opacity
let frac: f32 = 1.0 - (diff as f32 / self.aa_level.pow(2) as f32);
let alpha = f32::from(image.pixel(x, y).alpha()) / 255.0;
let frac: f32 = alpha - (diff as f32 / self.aa_level.pow(2) as f32);
return image.pixel(x, y).with_alpha((255.0 * frac) as u8);
}
}
Expand Down Expand Up @@ -88,7 +89,8 @@ impl TrapMask {
let diff: f32 = gpos - v;
if diff <= self.aa_level as f32 {
// Fraction of opacity
let frac = 1.0 - (diff / (self.aa_level as f32));
let alpha = f32::from(image.pixel(x, y).alpha()) / 255.0;
let frac = alpha - (diff / (self.aa_level as f32));
return image.pixel(x, y).with_alpha((255.0 * frac) as u8);
}
Rgba::transparent()
Expand Down

0 comments on commit 0f25654

Please sign in to comment.