Color History now only shows unique colors

This commit is contained in:
2022-06-07 13:23:03 +02:00
parent 0f4d845fd8
commit 1a468895ad

View File

@@ -69,25 +69,22 @@ namespace Paint_2
public List<Color> SandartGetLastColors(int colorNumber) public List<Color> SandartGetLastColors(int colorNumber)
{ {
List<Color> result = new List<Color>(); List<Color> result = new List<Color>();
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 Color targetColor = Target.Colors[(Target.Colors.Count) - i];
for (int i = Target.Colors.Count; i > 0; i--) if (result.Count == 0 || result[result.Count - 1] != targetColor)
{ {
result.Add(Target.Colors[(Target.Colors.Count) - i]); result.Add(targetColor);
}
for (int i = colorNumber - Target.Colors.Count; i > 0; i--)
{
result.Add(Color.FromArgb(0x00, 0x00, 0x00));
} }
} }
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(Color.FromArgb(0x00, 0x00, 0x00));
{
result.Add(Target.Colors[(Target.Colors.Count) - i]);
}
} }
result.Reverse();
return result; return result;
} }
public Point Lerp(Point start, Point end, float t) public Point Lerp(Point start, Point end, float t)