View Raw SPL
/*****************************************************************************
* *
* SUMMER.SPL Copyright (C) 2018 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Generate a colormap of green, yellow *
* *
* Revisions: 30 Mar 2018 RRR Creation *
* *
*****************************************************************************/
#if @HELP_SUMMER
SUMMER
Purpose: Generates a colormap from green to yellow.
Syntax: SUMMER(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)');
summer;
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 green (lowest) to
yellow (highest).
Example:
spring(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 colors ranging from green (lowest) to
yellow (highest).
Remarks:
SUMMER() by itself sets the colormap and shading.
a = spring() or setcolormap(spring()) 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
Bone
Cool
Copper
Gray
Hot
Hsv
Parula
Pink
Rainbow
Setcolormap
Setshading
Showcmap
Spring
Winter
#endif
/* summer colormap */
summer(cmaplen)
{
local rgb;
if (argc < 1)
{
cmaplen = length(getcolormap());
}
/* RGB colors */
rgb = (0..(cmaplen - 1)) / max(1, cmaplen - 1);
rgb = ravel(rgb, rgb / 2 + 0.5, 0.4 * ones(cmaplen, 1));
if (outargc == 0)
{
/* set the colormap and shading */
setplotshading(rgb);
}
else
{
/* return the colormap */
setrgbprops(rgb);
return(rgb);
}
}