Skip to content

Commit

Permalink
Fix color blending in fontdue renderer
Browse files Browse the repository at this point in the history
Dividing by 256 (instead of correct 255) produced GIFs that were 0.4%
darker than they should have been.
  • Loading branch information
ku1ik committed Nov 13, 2023
1 parent 4ef524c commit ec02812
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/renderer/fontdue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ fn mix_colors(fg: RGBA8, bg: RGBA8, ratio: u8) -> RGBA8 {
let ratio = ratio as u16;

RGBA8::new(
((bg.r as u16) * (255 - ratio) / 256) as u8 + ((fg.r as u16) * ratio / 256) as u8,
((bg.g as u16) * (255 - ratio) / 256) as u8 + ((fg.g as u16) * ratio / 256) as u8,
((bg.b as u16) * (255 - ratio) / 256) as u8 + ((fg.b as u16) * ratio / 256) as u8,
((bg.r as u16) * (255 - ratio) / 255) as u8 + ((fg.r as u16) * ratio / 255) as u8,
((bg.g as u16) * (255 - ratio) / 255) as u8 + ((fg.g as u16) * ratio / 255) as u8,
((bg.b as u16) * (255 - ratio) / 255) as u8 + ((fg.b as u16) * ratio / 255) as u8,
255,
)
}
Expand Down

0 comments on commit ec02812

Please sign in to comment.