From 1a468895ad9df4091b88cf21fadc995b83b0a4f3 Mon Sep 17 00:00:00 2001 From: maxluli Date: Tue, 7 Jun 2022 13:23:03 +0200 Subject: [PATCH] Color History now only shows unique colors --- Paint_2/PaintToolUtils.cs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Paint_2/PaintToolUtils.cs b/Paint_2/PaintToolUtils.cs index bcf1684..56c6001 100644 --- a/Paint_2/PaintToolUtils.cs +++ b/Paint_2/PaintToolUtils.cs @@ -69,25 +69,22 @@ namespace Paint_2 public List SandartGetLastColors(int colorNumber) { List result = new List(); - if (Target.Colors.Count <= colorNumber) + + //We need to fill with black color + for (int i = Target.Colors.Count; i > 0; i--) { - //We need to fill with black color - for (int i = Target.Colors.Count; i > 0; i--) + Color targetColor = Target.Colors[(Target.Colors.Count) - i]; + if (result.Count == 0 || result[result.Count - 1] != targetColor) { - result.Add(Target.Colors[(Target.Colors.Count) - i]); - } - for (int i = colorNumber - Target.Colors.Count; i > 0; i--) - { - result.Add(Color.FromArgb(0x00, 0x00, 0x00)); + result.Add(targetColor); } } - else + //for (int i = colorNumber - Target.Colors.Count; i > 0; i--) + for (int i = colorNumber - result.Count; i > 0; i--) { - for (int i = colorNumber; i > 0; i--) - { - result.Add(Target.Colors[(Target.Colors.Count) - i]); - } + result.Add(Color.FromArgb(0x00, 0x00, 0x00)); } + result.Reverse(); return result; } public Point Lerp(Point start, Point end, float t)