Mercurial > octave
diff scripts/image/copper.m @ 32647:dfb9b770ae77
Increase default colormap size to 256 colors, add colormap BISTs (bug #65010)
* autumn.m, bone.m, cool.m, copper.m, cubehelix.m, flag.m, gray.m, hot.m,
hsv.m, jet.m, lines.m, ocean.m, prism.m, rainbow.m, spring.m, summer.m,
turbo.m, viridis.m, white.m, winter.m: Change default return size from 64 to
256. Update docstring text about colormap size being either the size of the
current colomap or the default of 256. Add function BISTs for calling forms
and input validation.
* colorcube.m: Update input validation to match other colormaps. Change
default return size from 64 to 256. Update docstring text about colormap
size being either the size of the current colomap or the default of 256.
Add function BISTs for calling forms and input validation.
* colormap.m: Update default colormap size to 256. Add docstring noting new
colormap size and that colormap will create a new figure if one does not
exist. Update BISTs for new size.
* graphics.cc (viridis_colormap): Replace 64 color interpolated viridis map
table with full 256 color map. Increase cmap container size to 256.
* NEWS.10.md: Note increased size of default return from colormap functions.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Mon, 25 Dec 2023 18:35:50 -0500 |
parents | 2e484f9f1f18 |
children | 8dfe116fb0fe |
line wrap: on
line diff
--- a/scripts/image/copper.m Sat Dec 23 14:14:26 2023 +0100 +++ b/scripts/image/copper.m Mon Dec 25 18:35:50 2023 -0500 @@ -30,7 +30,8 @@ ## tone. ## ## The argument @var{n} must be a scalar. -## If unspecified, the length of the current colormap, or 64, is used. +## If @var{n} is not specified the length of the current colormap is used. If +## there is no current colormap the default value of 256 is used. ## @seealso{colormap} ## @end deftypefn @@ -46,7 +47,7 @@ if (! isempty (hf)) n = rows (get (hf, "colormap")); else - n = 64; + n = 256; endif endif @@ -73,3 +74,26 @@ %! rgbplot (cmap, "composite"); %! subplot (2, 1, 2); %! rgbplot (cmap); + + +%!assert (size (copper ()), [256, 3]) +%!assert (size (copper (16)), [16, 3]) + +%!assert (copper (1), [0, 0, 0]) +%!assert (copper (true), double ([0, 0, 0])) +%!assert (copper (char (1)), double ([0, 0, 0])) +%!assert (copper (int32 (1)), double ([0, 0, 0])) + +%!assert (copper (0), zeros (0, 3)) +%!assert (copper (-1), zeros (0, 3)) + +%!test +%! a = [0.25, 0.15624, 0.0995] .* [0:5]'; +%! a(6) = 1; +%! assert (copper (6), a, eps) + +## Input validation +%!error <function called with too many inputs> copper (1, 2) +%!error <N must be a scalar> copper ("foo") +%!error <N must be a scalar> copper ([1, 2, 3]) +%!error <N must be a scalar> copper ({1, 2, 3})