D27017: [KColorUtils] Add hue(), chroma() and getHcyColor()

Noah Davis noreply at phabricator.kde.org
Mon Feb 3 21:26:46 GMT 2020


ndavis added a comment.


  I emailed Matthew Woehlke:
  
  Me:
  
  > I noticed that the minimum value for hue was -0.166667 (#ff00ff) and
  >  the maximum was almost 0.833333 (slightly less red than #ff00ff). Is
  >  this intentional or a bug? It's a bit hard to tell how the math is
  >  meant to work.
  
  Matthew Woehlke:
  
  > I assume you're talking about the hue that is calculated when converting
  >  *from* RGB?
  > 
  > Yes, that looks intentional. There are three branches for computing the
  >  hue, based on which component is "dominant" (i.e. has the largest
  >  value), which produce values of 0/3, 1/3 and 2/3, ±1/6.
  > 
  > Keep in mind that "hue" is a cyclic value, i.e. h=1.5 is perfectly valid
  >  and should produce the same result as h=0.5, h=-0.5, etc. (Note that
  >  conversion *to* RGB starts by normalizing hue.)
  > 
  > Basically, since it is desirable to accept denormalized hue anyway, it
  >  is slightly easier (read: less code, fewer machine instructions) to not
  >  bother normalizing it in conversion from RGB. If you are extracting HCY
  >  values for display purposes, you should apply the `wrap` helper function
  >  to the value first.

REPOSITORY
  R273 KGuiAddons

REVISION DETAIL
  https://phabricator.kde.org/D27017

To: ndavis, #frameworks, dfaure
Cc: broulik, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200203/3a97da62/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list