View Raw SPL
/*****************************************************************************
*                                                                            *
*   HOT.SPL        Copyright (C) 1997 DSP Development Corporation            *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Generate a colormap of black, red, yellow, white            *
*                                                                            *
*   Revisions:    4 Aug 1997  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/


#if @HELP_HOT

    HOT

    Purpose: Generates a colormap of black, red, yellow, white.

    Syntax:  HOT(len)

               len - optional colormap length, defaults to
                     the length of the current colormap


    Returns: A table of RGB triples suitable for the SETCOLORMAP function.

    Example:

             clen = length(getcolormap());
             density(ravel(rep(0..(clen-1), 32), clen)');
             hot();

             Creates a table of 32 x colormap length RBG values and
             displays the resulting colors. The resulting image is a
             vertical plot of colors ranging from black (lowest) to red
             to yellow to white (highest).

     Remarks:

             Hot() by itself sets the colormap and shading.

             a = hot() or setcolormap(hot()) returns the rgb values.
             In this case, use SETSHADING to make the new colormap
             take effect on an existing density or 2D plot.

     See Also:

             Cool
             Rainbow
             Setcolormap
             Setshading
             Showcmap

#endif


hot(mlen)
{
        local n, r, g, b, cmap;

        if (argc < 1)
        {
                mlen = length(getcolormap());
        }

        n = fix(3 / 8 * mlen);

        /* generate black, red, yellow, white rgb values */
        r = {(1..n) / n, ones(mlen - n, 1)};
        g = {zeros(n, 1), (1..n) / n, ones(mlen - 2*n, 1)};
        b = {zeros(2*n, 1), (1..mlen - 2*n) / (mlen - 2*n)};

        cmap = ravel(r, g, b);

        if (outargc == 0)
        {
                setplotshading(cmap);
        }
        else
        {
                /* return the colormap */
                setrgbprops(cmap);
                
                return(cmap);
        }
}