ker/mod/tfw.color.js
function rgb2hsl() {
    const
        R = this.R,
        G = this.G,
        B = this.B,
        min = Math.min( R, G, B ),
        max = Math.max( R, G, B ),
        delta = max - min;

    this.L = 0.5 * ( max + min );

    if ( delta < 0.000001 ) {
        this.H = 0;
        this.S = 0;
    } else {
        this.S = delta / ( 1 - Math.abs( ( 2 * this.L ) - 1 ) );
        if ( max === R ) {
            if ( G >= B ) {
                this.H = INV6 * ( ( G - B ) / delta );
            } else {
                this.H = 1 - ( INV6 * ( ( B - G ) / delta ) );
            }
        } else if ( max === G ) {
            this.H = INV6 * ( 2 + ( ( B - R ) / delta ) );
        } else {
            this.H = INV6 * ( 4 + ( ( R - G ) / delta ) );
        }
    }
}
function rgb2hsl() {
    const
        R = this.R,
        G = this.G,
        B = this.B,
        min = Math.min( R, G, B ),
        max = Math.max( R, G, B ),
        delta = max - min;

    this.L = 0.5 * ( max + min );

    if ( delta < 0.000001 ) {
        this.H = 0;
        this.S = 0;
    } else {
        this.S = delta / ( 1 - Math.abs( ( 2 * this.L ) - 1 ) );
        if ( max === R ) {
            if ( G >= B ) {
                this.H = INV6 * ( ( G - B ) / delta );
            } else {
                this.H = 1 - ( INV6 * ( ( B - G ) / delta ) );
            }
        } else if ( max === G ) {
            this.H = INV6 * ( 2 + ( ( B - R ) / delta ) );
        } else {
            this.H = INV6 * ( 4 + ( ( R - G ) / delta ) );
        }
    }
}
function rgb2hsl ( ) { const R = this . R , G = this . G , B = this . B , min = Math . min ( R , G , B ) , max = Math . max ( R , G , B ) , delta = max - min ; this . L = 0.5 * ( max + min ) ; if ( delta < 0.000001 ) { this . H = 0 ; this . S = 0 ; } else { this . S = delta / ( 1 - Math . abs ( ( 2 * this . L ) - 1 ) ) ; if ( max === R ) { if ( G >= B ) { this . H = INV6 * ( ( G - B ) / delta ) ; } else { this . H = 1 - ( INV6 * ( ( B - G ) / delta ) ) ; } } else if ( max === G ) { this . H = INV6 * ( 2 + ( ( B - R ) / delta ) ) ; } else { this . H = INV6 * ( 4 + ( ( R - G ) / delta ) ) ; } } }
Read R,G,B and write H,S,L.
@this Color
@returns {undefined}
Read R G B and write H S L .