Mercurial > octave-antonio
annotate scripts/image/colormap.m @ 20158:7503499a252b stable
doc: Update docstrings to have one sentence summary as first line.
Update scripts in audio, elfun, general, geometry, and image directories.
* scripts/audio/@audioplayer/__get_properties__.m,
scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/get.m,
scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/play.m,
scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/set.m,
scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m,
scripts/audio/@audiorecorder/audiorecorder.m,
scripts/audio/@audiorecorder/get.m,
scripts/audio/@audiorecorder/getaudiodata.m,
scripts/audio/@audiorecorder/getplayer.m,
scripts/audio/@audiorecorder/isrecording.m,
scripts/audio/@audiorecorder/play.m, scripts/audio/@audiorecorder/record.m,
scripts/audio/@audiorecorder/recordblocking.m,
scripts/audio/@audiorecorder/set.m, scripts/audio/@audiorecorder/stop.m,
scripts/audio/@audiorecorder/subsasgn.m,
scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m,
scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m,
scripts/audio/soundsc.m, scripts/audio/wavread.m, scripts/audio/wavwrite.m,
scripts/elfun/cosd.m, scripts/elfun/sind.m, scripts/elfun/tand.m,
scripts/general/accumarray.m, scripts/general/accumdim.m,
scripts/general/bitcmp.m, scripts/general/bitget.m, scripts/general/bitset.m,
scripts/general/blkdiag.m, scripts/general/cart2pol.m,
scripts/general/cart2sph.m, scripts/general/cell2mat.m,
scripts/general/celldisp.m, scripts/general/chop.m,
scripts/general/circshift.m, scripts/general/common_size.m,
scripts/general/cplxpair.m, scripts/general/cumtrapz.m,
scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/del2.m,
scripts/general/display.m, scripts/general/divergence.m,
scripts/general/fieldnames.m, scripts/general/flip.m,
scripts/general/flipdim.m, scripts/general/fliplr.m, scripts/general/flipud.m,
scripts/general/gradient.m, scripts/general/interp3.m,
scripts/general/interpft.m, scripts/general/interpn.m,
scripts/general/loadobj.m, scripts/general/logspace.m,
scripts/general/methods.m, scripts/general/nargchk.m,
scripts/general/narginchk.m, scripts/general/nargoutchk.m,
scripts/general/nextpow2.m, scripts/general/nthargout.m,
scripts/general/num2str.m, scripts/general/pol2cart.m,
scripts/general/polyarea.m, scripts/general/postpad.m,
scripts/general/prepad.m, scripts/general/profile.m, scripts/general/quadgk.m,
scripts/general/quadl.m, scripts/general/quadv.m, scripts/general/randi.m,
scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m,
scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m,
scripts/general/shiftdim.m, scripts/general/sortrows.m,
scripts/general/sph2cart.m, scripts/general/structfun.m,
scripts/general/subsindex.m, scripts/general/trapz.m,
scripts/general/triplequad.m, scripts/geometry/delaunayn.m,
scripts/geometry/dsearch.m, scripts/geometry/dsearchn.m,
scripts/geometry/griddata.m, scripts/geometry/griddata3.m,
scripts/geometry/griddatan.m, scripts/geometry/inpolygon.m,
scripts/geometry/rectint.m, scripts/geometry/tsearchn.m,
scripts/geometry/voronoi.m, scripts/geometry/voronoin.m,
scripts/help/__unimplemented__.m, scripts/help/doc.m,
scripts/help/doc_cache_create.m, scripts/help/get_first_help_sentence.m,
scripts/help/help.m, scripts/help/lookfor.m, scripts/help/print_usage.m,
scripts/help/type.m, scripts/help/which.m, scripts/image/autumn.m,
scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m,
scripts/image/colorcube.m, scripts/image/contrast.m, scripts/image/cool.m,
scripts/image/copper.m, scripts/image/cubehelix.m, scripts/image/flag.m,
scripts/image/gmap40.m, scripts/image/gray.m, scripts/image/gray2ind.m,
scripts/image/hot.m, scripts/image/hsv.m, scripts/image/image.m,
scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m,
scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m,
scripts/image/iscolormap.m, scripts/image/jet.m, scripts/image/lines.m,
scripts/image/ntsc2rgb.m, scripts/image/ocean.m, scripts/image/pink.m,
scripts/image/prism.m, scripts/image/rainbow.m, scripts/image/rgb2ntsc.m,
scripts/image/spinmap.m, scripts/image/spring.m, scripts/image/summer.m,
scripts/image/white.m, scripts/image/winter.m:
Update docstrings to have one sentence summary as first line.
Re-structure to have line lengths <= 80 chars.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 03 May 2015 09:36:20 -0700 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19667
diff
changeset
|
1 ## Copyright (C) 1994-2015 John W. Eaton |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
2 ## Copyright (C) 2012 Carnë Draug |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
1024 | 19 |
3381 | 20 ## -*- texinfo -*- |
14246
8b220af26cfb
doc: Update docstring for colormap()
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
21 ## @deftypefn {Function File} {@var{cmap} =} colormap () |
8b220af26cfb
doc: Update docstring for colormap()
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{cmap} =} colormap (@var{map}) |
8b220af26cfb
doc: Update docstring for colormap()
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
23 ## @deftypefnx {Function File} {@var{cmap} =} colormap ("default") |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
24 ## @deftypefnx {Function File} {@var{cmap} =} colormap ("@var{map_name}") |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
25 ## @deftypefnx {Function File} {@var{cmap} =} colormap (@var{hax}, @dots{}) |
16947
24bb7dc754ed
Document command form of colormap().
Carnë Draug <carandraug@octave.org>
parents:
16946
diff
changeset
|
26 ## @deftypefnx {Command} {} colormap @var{map_name} |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
27 ## @deftypefnx {Function File} {@var{cmaps} =} colormap ("list") |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
28 ## @deftypefnx {Function File} {} colormap ("register", "@var{name}") |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
29 ## @deftypefnx {Function File} {} colormap ("unregister", "@var{name}") |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14246
diff
changeset
|
30 ## Query or set the current colormap. |
3426 | 31 ## |
16946
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
32 ## With no input arguments, @code{colormap} returns the current color map. |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
33 ## |
3373 | 34 ## @code{colormap (@var{map})} sets the current colormap to @var{map}. The |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14246
diff
changeset
|
35 ## colormap should be an @var{n} row by 3 column matrix. The columns |
3373 | 36 ## contain red, green, and blue intensities respectively. All entries |
14260
1f911333ed3d
doc: Update docstrings for functions in image/ directory
Rik <octave@nomad.inbox5.com>
parents:
14246
diff
changeset
|
37 ## must be between 0 and 1 inclusive. The new colormap is returned. |
3426 | 38 ## |
6895 | 39 ## @code{colormap ("default")} restores the default colormap (the |
40 ## @code{jet} map with 64 entries). The default colormap is returned. | |
3426 | 41 ## |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
42 ## The map may also be specified by a string, @qcode{"@var{map_name}"}, where |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
43 ## @var{map_name} is the name of a function that returns a colormap. |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
44 ## |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
45 ## If the first argument @var{hax} is an axes handle, then the colormap for |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
46 ## the parent figure of @var{hax} is queried or set. |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
47 ## |
16947
24bb7dc754ed
Document command form of colormap().
Carnë Draug <carandraug@octave.org>
parents:
16946
diff
changeset
|
48 ## For convenience, it is also possible to use this function with the |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
49 ## command form, @code{colormap @var{map_name}}. |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
50 ## |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
51 ## @code{colormap ("list")} returns a cell array with all of the available |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
52 ## colormaps. The options @qcode{"register"} and @qcode{"unregister"} |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
53 ## add or remove the colormap @var{name} from this list. |
16947
24bb7dc754ed
Document command form of colormap().
Carnë Draug <carandraug@octave.org>
parents:
16946
diff
changeset
|
54 ## |
6895 | 55 ## @seealso{jet} |
3373 | 56 ## @end deftypefn |
559 | 57 |
3202 | 58 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312 | 59 ## Created: July 1994 |
60 ## Adapted-By: jwe | |
904 | 61 |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
62 function cmap = colormap (varargin) |
19610
965384560122
colormap.m: memory lock function to protect persistent variable from clear().
Carnë Draug <carandraug@octave.org>
parents:
19593
diff
changeset
|
63 mlock; # prevent map_list to be cleared by "clear all" |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
64 persistent map_list = cell (); |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
65 |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
66 [hax, varargin, nargin] = __plt_get_axis_arg__ ("colormap", varargin{:}); |
559 | 67 |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
68 if (nargin > 2) |
5923 | 69 print_usage (); |
1062 | 70 endif |
559 | 71 |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
72 if (! isempty (hax)) |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
73 cf = ancestor (hax, "figure"); |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
74 else |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
75 cf = get (0, "currentfigure"); |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
76 endif |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
77 |
1024 | 78 if (nargin == 1) |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
79 map = varargin{1}; |
5443 | 80 if (ischar (map)) |
1024 | 81 if (strcmp (map, "default")) |
6895 | 82 map = jet (64); |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
83 elseif (strcmp (map, "list")) |
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
84 cmap = map_list; |
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
85 return; |
559 | 86 else |
6257 | 87 map = feval (map); |
559 | 88 endif |
3238 | 89 endif |
90 | |
91 if (! isempty (map)) | |
15714
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15683
diff
changeset
|
92 if (! (isnumeric (map) && isreal (map) |
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15683
diff
changeset
|
93 && ndims (map) == 2 && columns (map) == 3)) |
b1cd65881592
Clean up scripts in image directory.
Rik <rik@octave.org>
parents:
15683
diff
changeset
|
94 error ("colormap: MAP must be a real-valued N x 3 ([R,G,B]) matrix"); |
3238 | 95 endif |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14640
diff
changeset
|
96 if (any (map(:) < 0) || any (map(:) > 1)) |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14640
diff
changeset
|
97 error ("colormap: all MAP values must be in the range [0,1]"); |
3238 | 98 endif |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
99 if (isempty (cf)) |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
100 cf = gcf (); |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
101 endif |
2303 | 102 ## Set the new color map |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
103 set (cf, "colormap", map); |
559 | 104 endif |
3238 | 105 |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
106 elseif (nargin == 2) |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
107 opt = varargin{1}; |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
108 name = varargin{2}; |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
109 if (! ischar (opt) || ! any (strcmp (opt, {"register", "unregister"}))) |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
110 print_usage (); |
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
111 elseif (! ischar (name)) |
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
112 error ("colormap: to register/unregister a colormap, NAME must be a string"); |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
113 elseif (strcmp (opt, "register")) |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
114 map_list{end+1} = name; |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
115 elseif (strcmp (opt, "unregister")) |
14640
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
116 map_list(strcmp (name, map_list)) = []; |
b9c02ee24de1
new colormap options
Carnë Draug <carandraug+dev@gmail.com>
parents:
14260
diff
changeset
|
117 endif |
559 | 118 endif |
119 | |
2303 | 120 ## Return current color map. |
7108 | 121 if (nargout > 0 || (nargout == 0 && nargin == 0)) |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
122 if (isempty (cf)) |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
123 cf = gcf (); |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
124 endif |
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
125 cmap = get (cf, "colormap"); |
6762 | 126 endif |
1024 | 127 |
559 | 128 endfunction |
15683
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14640
diff
changeset
|
129 |
806ea52af230
Overhaul m-files in image directory to provide better support for images stored as integers.
Rik <rik@octave.org>
parents:
14640
diff
changeset
|
130 |
16946
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
131 %!demo |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
132 %! ## Create an image for displaying a colormap |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
133 %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
134 %! axis ([1, 64, 0, 1], "ticy", "xy"); |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
135 %! ## Show 'jet' colormap |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
136 %! colormap (jet (64)); |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
137 %! title "colormap (jet (64))" |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
138 %! disp ("Press a key to continue"); |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
139 %! pause (); |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
140 %! ## Show 'colorcube' colormap |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
141 %! colormap (colorcube (64)); |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
142 %! title "colormap (colorcube (64))" |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
143 |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
144 %!test |
17305
ab71b9829752
colormap.m: Support axis handle as first argument.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
145 %! hf = figure ("visible", "off"); |
19667
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
146 %! unwind_protect |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
147 %! cmaptst = [0 1 0; 1 0 1; 1 1 1]; |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
148 %! cmap = colormap (cmaptst); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
149 %! assert (cmap, cmaptst); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
150 %! cmap = colormap (); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
151 %! assert (cmap, cmaptst); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
152 %! cmap = (get (gcf, "colormap")); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
153 %! assert (cmap, cmaptst); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
154 %! colormap ("default"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
155 %! assert (colormap (), jet (64)); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
156 %! colormap ("ocean"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
157 %! assert (colormap, ocean (64)); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
158 %! unwind_protect_cleanup |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
159 %! close (hf); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
160 %! end_unwind_protect |
16946
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
161 |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
162 %!test |
19667
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
163 %! hf = figure ("visible", "off"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
164 %! unwind_protect |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
165 %! cmaplst = colormap ("list"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
166 %! assert (iscell (cmaplst)); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
167 %! colormap ("register", "__mycmap__"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
168 %! cmaplst2 = colormap ("list"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
169 %! assert (numel (cmaplst2), numel (cmaplst) + 1); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
170 %! assert (any (strcmp (cmaplst2, "__mycmap__"))); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
171 %! colormap ("unregister", "__mycmap__"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
172 %! cmaplst2 = colormap ("list"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
173 %! assert (numel (cmaplst2), numel (cmaplst)); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
174 %! assert (! any (strcmp (cmaplst2, "__mycmap__"))); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
175 %! ## Unregister again and verify that nothing has happened |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
176 %! colormap ("unregister", "__mycmap__"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
177 %! cmaplst3 = colormap ("list"); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
178 %! assert (isequal (cmaplst2, cmaplst3)); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
179 %! unwind_protect_cleanup |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
180 %! close (hf); |
4b1a43786489
colormap.m: Don't show a figure during 'make check'
Mike Miller <mtmiller@ieee.org>
parents:
19610
diff
changeset
|
181 %! end_unwind_protect |
16946
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
182 |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
183 ## Test input validation |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
184 %!error colormap (1,2,3) |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
185 %!error <MAP must be a real-valued N x 3> colormap ({1,2,3}) |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
186 %!error <MAP must be a real-valued N x 3> colormap ([1 i 1]) |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
187 %!error <MAP must be a real-valued N x 3> colormap (ones(3,3,3)) |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
188 %!error <MAP must be a real-valued N x 3> colormap ([1 0 1 0]) |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
189 %!error <all MAP values must be in the range> colormap ([-1 0 0]) |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
190 %!error <all MAP values must be in the range> colormap ([2 0 0]) |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
191 %!error colormap ("invalid", "name") |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
192 %!error <NAME must be a string> colormap ("register", 1) |
92f42d9f2ae4
colormap.m: Add demos, tests, and warning when using deprecated syntax.
Rik <rik@octave.org>
parents:
16766
diff
changeset
|
193 |