From f6e3b1e438db50a8854ddf8f4940bc74a83e9ef7 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Fri, 27 Sep 2024 15:47:00 -0500 Subject: [PATCH] Fix label color blending --- GUI/Model/ModList.cs | 2 ++ GUI/Util.cs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/GUI/Model/ModList.cs b/GUI/Model/ModList.cs index 526582944..be46fbf74 100644 --- a/GUI/Model/ModList.cs +++ b/GUI/Model/ModList.cs @@ -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() + // No transparent blending + .Where(c => c.A == byte.MaxValue) .ToArray()) : Color.Transparent; diff --git a/GUI/Util.cs b/GUI/Util.cs index 3f0cc74e6..1fb4790a7 100644 --- a/GUI/Util.cs +++ b/GUI/Util.cs @@ -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),