/* Compare, compares to given colors. If colors are not equal * the color closest to white is larger color. * * @param a, the color to be compared to * @param b. the color to compare * * @return 0: a == b * @return 1: a > b * @return -1: a < b */ public static int Compare(MColor a, MColor b) { if (a is null && b is null) { return(0); } //A non null color is greater than a null color if (b is null) { return(1); } //A null color is not greater than non null color if (a is null) { return(-1); } if (a.Name == b.Name && a.HexColor == b.HexColor) { return(0); } Color ca = a.GetColor(); Color cb = b.GetColor(); float total = 0; total += ca.r - cb.r; total += ca.g - cb.g; total += ca.b - cb.b; return(total > 0 ? 1 : (total == 0 ? 0 : -1)); }