色ソート
static void Main() { var c1 = Color.FromArgb( 0x21, 0xc1, 0x3a, 0x72 ); var c2 = Color.FromArgb( 0x71, 0xcc, 0xcc, 0xcc ); var c3 = Color.FromArgb( 0x21, 0xe4, 0x91, 0x59 ); var c4 = Color.FromArgb( 0xFF, 0xe4, 0x91, 0x60 ); Dictionary<string, double> rList=new Dictionary<string, double> { {"c2", Range(c1, c2)}, {"c3", Range(c1, c3)}, {"c4", Range(c1, c4)} }; var s = rList.OrderBy(p => p.Value); foreach (var pair in s) { Console.WriteLine(pair.Key); } } static double Range( Color c1, Color c2 ) { return Math.Sqrt( Math.Pow( c1.R - c2.R, 2 ) + Math.Pow( c1.G - c2.G, 2 ) + Math.Pow( c1.B - c2.B, 2 ) + Math.Pow( c1.A - c2.A, 2 ) ); }
alpha入れると場が荒れるな。
背景色によってだいぶ左右されそうだけど
やっぱり濃さよりも色相のほうが優先度高そうに思えなくもない。