There are good libraries these days for color space conversion such as Colorful To match for visual difference, convert to HSV/HSL or if you are really ambitious a more exotic color space like CIE XYZ where "distance" closely represents similarity. Whichever color in the ACI array that has the smallest dist, is the closest match to r,g,b.Įdit: as has been pointed out: RGB distance isn't good as a visual/perceptive difference. To do a "closest" match backwards lookup from RGB, simply do a pass over that array and return the color with minimum distance (for example by checking the squared distances of the 3 color channels: if your color is r,g,b and the aci color is R,G,B then the distance is dist = (r-R)*(r-R) + (g-G)*(g-G) + (b-B)*(b-B) To get an ACI color by index, simply pick the color from that list. Take the RGB values of all the ACI colors from some source (for example ) and create an array of ACI colors.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |