Search code examples
objective-ciosrgbuicolorhsl

RGB to HSL conversion seems OK value-vise, but not visually


a noob question here.

  1. let's say I have RGB values of: R:53,G:37 and B:11
  2. so i set a background color of a rectangle with:

    [UIColor colorWithRed:0.53 green:0.37 blue:0.11 alpha:1.00];

  3. now I do a RGB to HSL conversion that yields: H:0.10,is S:0.16 and L:0.13

  4. so i set a background color of the same rectangle with:

    [UIColor colorWithHue:0.10 saturation:0.16 brightness:0.13 alpha:1.00];

the thing is that the HSL color looks nothing like the RGB color. I compared my conversion result against an online converter and it looks OK as far as I can tell.

I am most likely interpreting something incorrectly.


Solution

  • The UIColor function applies HSB which is different to HSL.