1024
|
1 # Copyright (C) 1995 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 the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # 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, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
18 |
|
19 function cmap = colormap (map) |
559
|
20 |
904
|
21 # Set the current colormap. |
|
22 # |
1024
|
23 # colormap (map) sets the current colormap to map. map should be an n |
|
24 # row by 3 column matrix. The columns contain red, green, and blue |
|
25 # intensities respectively. All entries should be between 0 and 1 |
|
26 # inclusive. The new colormap is returned. |
904
|
27 # |
1024
|
28 # colormap ("default") restores the default colormap (a gray scale |
|
29 # colormap with 64 entries). The default colormap is returned. |
904
|
30 # |
|
31 # colormap with no arguments returns the current colormap. |
|
32 |
1024
|
33 # Written by Tony Richardson (amr@mpl.ucsd.edu) July 1994. |
559
|
34 |
|
35 global CURRENT_COLOR_MAP |
|
36 |
1062
|
37 if (nargin > 1) |
|
38 usage ("colormap (map)"); |
|
39 endif |
559
|
40 |
1024
|
41 if (nargin == 1) |
|
42 if (isstr (map)) |
|
43 if (strcmp (map, "default")) |
559
|
44 CURRENT_COLOR_MAP = gray; |
|
45 else |
1024
|
46 error ("invalid argument"); |
559
|
47 endif |
|
48 else |
1024
|
49 # Set the new color map |
559
|
50 CURRENT_COLOR_MAP = map; |
|
51 endif |
1062
|
52 elseif (! exist ("CURRENT_COLOR_MAP")) |
1024
|
53 # If global color map doesn't exist, create the default map. |
559
|
54 CURRENT_COLOR_MAP = gray; |
|
55 endif |
|
56 |
1024
|
57 # Return current color map. |
|
58 |
559
|
59 cmap = CURRENT_COLOR_MAP; |
1024
|
60 |
559
|
61 endfunction |