Skip to content

Commit 3fdae25

Browse files
committed
Fix target snapshot regressions
1 parent cda78b5 commit 3fdae25

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/DiagramForge/Models/ThemePaletteResolver.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ public static string[] BuildRingColors(Theme theme, int ringCount, string center
157157
throw new ArgumentOutOfRangeException(nameof(ringCount), ringCount, "ringCount must be at least 1.");
158158

159159
var chromaticPalette = ResolveEffectivePalette(theme, Math.Max(DefaultPaletteSize, ringCount * 2));
160+
bool isThemePaletteMonochrome = theme.NodePalette is { Count: > 0 }
161+
&& ColorUtils.IsPaletteMonochrome(theme.NodePalette, theme.BackgroundColor);
160162

161163
var colors = new List<string>(ringCount)
162164
{
@@ -183,14 +185,20 @@ public static string[] BuildRingColors(Theme theme, int ringCount, string center
183185
for (int i = 0; i < theme.NodePalette.Count; i++)
184186
{
185187
string paletteColor = theme.NodePalette[i];
186-
string fallbackColor = chromaticPalette[i % chromaticPalette.Count];
187-
candidatePool.Add(ColorUtils.Vibrant(paletteColor, fallbackColor, 2.6));
188-
candidatePool.Add(ColorUtils.RotateHue(fallbackColor, 28, isLightBackground));
188+
if (isThemePaletteMonochrome)
189+
{
190+
string fallbackColor = chromaticPalette[i % chromaticPalette.Count];
191+
candidatePool.Add(ColorUtils.Vibrant(paletteColor, fallbackColor, 2.6));
192+
candidatePool.Add(ColorUtils.RotateHue(fallbackColor, 28, isLightBackground));
193+
}
194+
else
195+
{
196+
candidatePool.Add(ColorUtils.Vibrant(paletteColor, 2.6));
197+
candidatePool.Add(ColorUtils.RotateHue(paletteColor, 28, isLightBackground));
198+
}
189199
}
190200
}
191201

192-
candidatePool.AddRange(chromaticPalette);
193-
194202
var distinctCandidates = candidatePool
195203
.Select(color => ColorUtils.Blend(color, theme.BackgroundColor, isLightBackground ? 0.06 : 0.10))
196204
.Distinct(StringComparer.OrdinalIgnoreCase)

tests/DiagramForge.E2ETests/Fixtures/conceptual-target-prism.expected.svg

Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)