View Raw SPL
static cmapobj;


/* integer to colormap */
_i2cmap(i)
{
        local s;

        if (argc < 1)
        {
                i = 0;
        }

        if (length(cmapobj) == 1)
        {
                cmapobj = _i2cmap_cmapobj();
        }

        s = cmapobj[i + 1];

        return(s);
}


/* make object that maps integers to colormap names */
_i2cmap_cmapobj()
{
        local cmaps, j, cstr;

        /* color maps as strings */
        cmaps = _chooseshading;

        /* cmap object */
        cmapobj = [];

        /* first one "none" */
        cmapobj[1] = _nonestr;

        j = 2;

        /* load up strings */
        do
        {
                cstr = strget(j, cmaps, strescape("\n"));

                if (strlen(cstr) == 0)
                {
                        break;
                }

                cmapobj[j] = cstr;

                j++;
        }
        while(1);
}