View Raw SPL
/*****************************************************************************
*                                                                            *
*   BONE.SPL   Copyright (C) 2018 DSP Development Corporation                *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Generate a colormap of shades of gray with blue tint        *
*                                                                            *
*   Revisions:   30 Mar 2018  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/


#if @HELP_BONE

    BONE

    Purpose: Generates a colormap with shades of gray with blue tint.

    Syntax:  BONE(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)');
             bone;

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

    Example:
             bone(256);showcmap

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

    Remarks:
             BONE() by itself sets the colormap and shading.

             a = bone() or setcolormap(bone()) 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:
             Autumn
             Cool
             Copper
             Gray
             Hot
             Hsv
             Parula
             Pink
             Rainbow
             Setcolormap
             Setshading
             Showcmap
             Spring
             Summer
             Winter
#endif


/* bone colormap */
bone(cmaplen)
{
        local rgb;

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

        /* RGB colors */
        rgb = fliplr((hot(cmaplen) + 7 * gray(cmaplen)) / 8);

        if (outargc == 0)
        {
                /* set the colormap and shading */
                setplotshading(rgb);
        }
        else
        {
                /* return the colormap */
                setrgbprops(rgb);

                return(rgb);
        }
}