3

For eg.

I have 3 colors.

color1 = UIColor(red: 142/255, green: 165/255, blue: 94/255, alpha: 1)

color2 = UIColor(red: 141/255, green: 114/255, blue: 96/255, alpha: 1)

color3 = UIColor(red: 214/255, green: 194/255, blue: 149/255, alpha: 1)

Is it possible to identify that color1 is closest to color2 and not color3 in swift and then make the necessary adjustments to color1 such that color1 == color2?

If you compare color1 and color2, you can see that they are of slightly different shades but are very very similar.

enter image description here

can I compare merely based on RGB values or do I have to use hex values?

Thanks

sinoroc
  • 18,409
  • 2
  • 39
  • 70
Ler Ws
  • 317
  • 5
  • 17
  • 1
    http://stackoverflow.com/questions/9018016/how-to-compare-two-colors – Larme Oct 17 '16 at 12:57
  • How do I obtain cieLab colors from UIColors? – Ler Ws Oct 17 '16 at 16:46
  • 1
    You can retrieve Hue&other stuff from `func getHue(_ hue: UnsafeMutablePointer?, saturation: UnsafeMutablePointer?, brightness: UnsafeMutablePointer?, alpha: UnsafeMutablePointer?) -> Bool` (there is a equivalent to get RGBA), then you have to compute them into CIELab if that's the technique of equals color you want to use, and check on WiKi for instance if there are formulas to get from one to the other. – Larme Oct 17 '16 at 16:49

0 Answers0