public static bool MakeSpecialIndicesUnique(this IPalette palette, out byte[] changed) { List <byte> clist = new List <byte>(); foreach (byte b in UniqueIndices) { Color c = palette.Get(b); if (palette.Count(c) > 1) // include self { int argb = c.ToArgb(); argb++; palette.Set(b, Color.FromArgb(255, Color.FromArgb(argb))); c = palette.Get(b); while (palette.Count(c) > 1) // include self { argb++; palette.Set(b, Color.FromArgb(255, Color.FromArgb(argb))); c = palette.Get(b); // use the get function, since we have 15-bit and 18-bit colour that could produce the same results with different RGB values. } clist.Add(b); } } changed = clist.ToArray(); return(changed.Length > 0); }
private ScottPlot.Plot TestColormap(IPalette cset, int lineWidth, bool dark = false) { var plt = new ScottPlot.Plot(600, 400); for (int i = 0; i < cset.Count(); i++) { double[] ys = DataGen.Sin(51, phase: -i / Math.PI / cset.Count()); var sig = plt.AddSignal(ys, color: cset.GetColor(i)); sig.MarkerSize = 0; sig.LineWidth = lineWidth; } if (dark) { plt.Style(Style.Gray1); plt.Style(darkColor, darkColor); } plt.Title($"Colorset '{cset.Name}' has {cset.Count()} colors"); plt.AxisAuto(0); return(plt); }
public static bool HasNonUniqueSpecialIndices(this IPalette palette, out byte[] affected) { List <byte> clist = new List <byte>(); foreach (byte b in UniqueIndices) { Color c = palette.Get(b); if (palette.Count(c) > 1) // include self { clist.Add(b); } } affected = clist.ToArray(); return(affected.Length > 0); }