Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

void sp_color_rgb_to_hsl_floatv ( float *  hsl,
float  r,
float  g,
float  b 
)

Fill hsl float array from r,g,b float values.

Definition at line 327 of file color.cpp.

Referenced by ColorScales::_colorChanged(), and compare_pixels().

{
    float max = MAX (MAX (r, g), b);
    float min = MIN (MIN (r, g), b);
    float delta = max - min;

    hsl[2] = (max + min)/2.0;

    if (delta == 0) {
        hsl[0] = 0;
        hsl[1] = 0;
    } else {
        if (hsl[2] <= 0.5)
            hsl[1] = delta / (max + min);
        else
            hsl[1] = delta / (2 - max - min);

        if (r == max) hsl[0] = (g - b) / delta;
        else if (g == max) hsl[0] = 2.0 + (b - r) / delta;
        else if (b == max) hsl[0] = 4.0 + (r - g) / delta;

        hsl[0] = hsl[0] / 6.0;

        if (hsl[0] < 0) hsl[0] += 1;
        if (hsl[0] > 1) hsl[0] -= 1;
    }
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index