Skip to content

Commit

Permalink
Fix label color blending
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 27, 2024
1 parent 286d3eb commit f6e3b1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions GUI/Model/ModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ public Color GetRowBackground(GUIMod mod, bool conflicted, string? instanceName,
.Where(l => l.ContainsModule(game, mod.Identifier))
.Select(l => l.Color)
.OfType<Color>()
// No transparent blending
.Where(c => c.A == byte.MaxValue)
.ToArray())
: Color.Transparent;

Expand Down
5 changes: 4 additions & 1 deletion GUI/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ public static Color BlendColors(Color[] colors)
=> colors.Length < 1 ? Color.Empty
//: colors is [var c] ? c
: colors.Length == 1 && colors[0] is var c ? c
: colors.Aggregate((back, fore) => fore.AlphaBlendWith(1f / colors.Length, back));
: Color.FromArgb(colors.Sum(c => c.A) / colors.Length,
colors.Sum(c => c.R) / colors.Length,
colors.Sum(c => c.G) / colors.Length,
colors.Sum(c => c.B) / colors.Length);

public static Color AlphaBlendWith(this Color c1, float alpha, Color c2)
=> AddColors(c1.MultiplyBy(alpha),
Expand Down

0 comments on commit f6e3b1e

Please sign in to comment.