View Raw SPL
/* define color given a RGB value */
rgbdefcolor(name = "", rgbcolor = 0, index = -1)
{
        local r, b, g, idx;

        if (not(isstring(name)) || strlen(name) == 0)
        {
                error(sprintf("%s - color name required", __FUNC__));
        }

        /* mask individual color values */
        r = rgbcolor & 0xFF0000;
        g = rgbcolor & 0x00FF00;
        b = rgbcolor & 0x0000FF;

        /* shift to 0-255 range */
        r >>= 16;
        g >>= 8;

        /* define color and return color index */
        idx = defcolor(name, r, g, b, index);

        return(idx);
}