2303
|
1 ### Copyright (C) 1996 John W. Eaton |
|
2 ### |
|
3 ### This file is part of Octave. |
|
4 ### |
|
5 ### Octave is free software; you can redistribute it and/or modify it |
|
6 ### under the terms of the GNU General Public License as published by |
|
7 ### the Free Software Foundation; either version 2, or (at your option) |
|
8 ### any later version. |
|
9 ### |
|
10 ### Octave is distributed in the hope that it will be useful, but |
|
11 ### WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ### General Public License for more details. |
|
14 ### |
|
15 ### You should have received a copy of the GNU General Public License |
|
16 ### along with Octave; see the file COPYING. If not, write to the Free |
|
17 ### Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ### 02111-1307, USA. |
1024
|
19 |
|
20 function cmap = colormap (map) |
559
|
21 |
2303
|
22 ## Set the current colormap. |
|
23 ## |
|
24 ## colormap (map) sets the current colormap to map. map should be an n |
|
25 ## row by 3 column matrix. The columns contain red, green, and blue |
|
26 ## intensities respectively. All entries should be between 0 and 1 |
|
27 ## inclusive. The new colormap is returned. |
|
28 ## |
|
29 ## colormap ("default") restores the default colormap (a gray scale |
|
30 ## colormap with 64 entries). The default colormap is returned. |
|
31 ## |
|
32 ## colormap with no arguments returns the current colormap. |
904
|
33 |
2303
|
34 ## Written by Tony Richardson (amr@mpl.ucsd.edu) July 1994. |
559
|
35 |
|
36 global CURRENT_COLOR_MAP |
|
37 |
1062
|
38 if (nargin > 1) |
|
39 usage ("colormap (map)"); |
|
40 endif |
559
|
41 |
1024
|
42 if (nargin == 1) |
|
43 if (isstr (map)) |
|
44 if (strcmp (map, "default")) |
559
|
45 CURRENT_COLOR_MAP = gray; |
|
46 else |
1024
|
47 error ("invalid argument"); |
559
|
48 endif |
|
49 else |
2303
|
50 ## Set the new color map |
559
|
51 CURRENT_COLOR_MAP = map; |
|
52 endif |
1062
|
53 elseif (! exist ("CURRENT_COLOR_MAP")) |
2303
|
54 ## If global color map doesn't exist, create the default map. |
559
|
55 CURRENT_COLOR_MAP = gray; |
|
56 endif |
|
57 |
2303
|
58 ## Return current color map. |
1024
|
59 |
559
|
60 cmap = CURRENT_COLOR_MAP; |
1024
|
61 |
559
|
62 endfunction |