static fromString(str)
    {
        const out = new Color();

        if (!str) return out;

        const firstChars = str.substring(0, 3);

        // assume "rgb()" or "rgba()" form
        if (firstChars === 'rgb')
        {
            const values = rgxRgbString.exec(str);

            if (values)
            {
                out.red = parseFloat(values[1], 10);
                out.green = parseFloat(values[2], 10);
                out.blue = parseFloat(values[3], 10);
            }
        }
        // assume hex form.
        else
        {
            // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
            str = str.replace(rgxHexShortString, (m, r, g, b) => (r + r + g + g + b + b));

            const values = rgxHexFullString.exec(str);

            if (values)
            {
                out.red = parseInt(values[1], 16);
                out.green = parseInt(values[2], 16);
                out.blue = parseInt(values[3], 16);
            }
        }

        return out;
    }
/**
     * Creates a color from a string.
     *
     * @param {string} str - The string representation of this color. e.g. "#AABBCC" or "rgb(255, 255, 255)"
     * @return {Color} The new color.
     */
Creates a color from a string.
@param {string} str - The string representation of this color.
Creates a color from a string . @param { string } str - The string representation of this color .
static fromString(str)
    {
        const out = new Color();
        if (!str) return out;
        const firstChars = str.substring(0, 3);
        if (firstChars === 'rgb')
        {
            const values = rgxRgbString.exec(str);
            if (values)
            {
                out.red = parseFloat(values[1], 10);
                out.green = parseFloat(values[2], 10);
                out.blue = parseFloat(values[3], 10);
            }
        }
        else
        {
            str = str.replace(rgxHexShortString, (m, r, g, b) => (r + r + g + g + b + b));
            const values = rgxHexFullString.exec(str);
            if (values)
            {
                out.red = parseInt(values[1], 16);
                out.green = parseInt(values[2], 16);
                out.blue = parseInt(values[3], 16);
            }
        }
        return out;
    }
static fromString ( str ) { const out = new Color ( ) ; if ( ! str ) return out ; const firstChars = str . substring ( 0 , 3 ) ; if ( firstChars === 'rgb' ) { const values = rgxRgbString . exec ( str ) ; if ( values ) { out . red = parseFloat ( values [ 1 ] , 10 ) ; out . green = parseFloat ( values [ 2 ] , 10 ) ; out . blue = parseFloat ( values [ 3 ] , 10 ) ; } } else { str = str . replace ( rgxHexShortString , ( m , r , g , b ) => ( r + r + g + g + b + b ) ) ; const values = rgxHexFullString . exec ( str ) ; if ( values ) { out . red = parseInt ( values [ 1 ] , 16 ) ; out . green = parseInt ( values [ 2 ] , 16 ) ; out . blue = parseInt ( values [ 3 ] , 16 ) ; } } return out ; }
Creates a color from a string.
Creates a color from a string .
// assume "rgb()" or "rgba()" form // assume hex form. // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")