我们正在建设一个体育应用程序,并希望将球队的颜色在应用程序的各个部分。
We are building a sports application and would like to incorporate team colors in various portions of the app.
现在每支球队可以重新$ P $用几种不同的颜色psented。
Now each team can be represented using several different colors.
我想要做的是进行检查,以验证这两个球队的颜色是否在一定范围内对方的范围内,所以,我不显示两个相似的颜色。
What I would like to do is to perform a check to verify whether the two team colors are within a certain range of each other, so that I do not display two similar colors.
因此,如果队1的主要球队颜色有RGB值(255,0,0)(或#FF0000),和2队的主要颜色是类似的,说RGB(250,0,0),然后我们会选择不同的颜色的球队之一。
So, if team 1's primary team color has a value of rgb(255,0,0) (or #FF0000), and team 2's primary color is similar, say rgb(250,0,0), then we would choose a different color for one of the teams.
如果可能的话,我有什么办法可以用来执行检查?
If possible, what approach could I take to perform the check?
感谢
下面是
和在C算法中:
typedef struct {
unsigned char r, g, b;
} RGB;
double ColourDistance(RGB e1, RGB e2)
{
long rmean = ( (long)e1.r + (long)e2.r ) / 2;
long r = (long)e1.r - (long)e2.r;
long g = (long)e1.g - (long)e2.g;
long b = (long)e1.b - (long)e2.b;
return sqrt((((512+rmean)*r*r)>>8) + 4*g*g + (((767-rmean)*b*b)>>8));
}
上一篇:算法来划分数字列表成2等于总和列表列表、总和、算法、数字
下一篇:如何分割字符串成单词。例如:" stringintowords" - > "串入词QUOT;?单词、字符、串成、QUOT