Skip to content
  • Wolthera van Hövell's avatar
    Adds HSI and HSY' to the advanced colour selector. · 0f5a2de4
    Wolthera van Hövell authored
    So, I want to add Intensity and Luma(The latter would be like mypaint)
    to the advanced colour selector options in Krita.
    But for that I first need conversion functions.
    
    HSI, intensity, uses a system where a color is mapped to a tone scale
    depending on the sum of it's components. So basically, Intensity=
    (r+b+g)/3.
    HSY, Luma, is similar, but it weights the components instead. So
    Luminosity=(r*R'+g*G'+b*B').
    Both are a little more intuitive to use for artists.
    
    Krita's Advanced c-pick currently uses QColor hsv and hsl functions
    through the display converter. This patch tries to add eight functions
    to KoColorConversions:
    *HSIToRGB, RGBToHSI, HCIToRGB, RGBToHCI.
    These functions are for converting from and to HSI, these functions use
    qreals in the range of 0.0-1.0.
    
    *HSYToRGB, RGBToHSY, HCYToRGB, RGBToHCY.
    These functions are for converting from and to HSY, these functions also
    use qreals in the range of 0.0-1.0. On top of that, they have extra
    parameters for setting the weights, which default to rec
    601(http://en.wikipedia.org/wiki/CCIR_601) when not specified.
    
    The difference between the HSI, HSY and HCI, HCY functions is that HSI
    and HSY maps to a cyllindrical space using a weighted HSL algorithm.
    This is useful for colour selectors because the output is more intuitive
    and has no unexpected shifts in either direction. The HCI and HCY
    functions on the other hand are the basic formulas and I put them in for
    compatibility.
    
    Implementation:
    The code is implemented in the advanced colour selector through
    kis_display_converter, where it creates or converts a qcolor for the
    proper values.
    
    In the advanced color selector itself we can now select shapes that use
    HSI and HSY, and we can request the MyPaint shade selector to use HSL,
    HSI and HSY. These options have been added to the settings window, with
    tooltips and all.
    0f5a2de4