559
|
1 function cmap = colormap(map) |
|
2 |
904
|
3 # Set the current colormap. |
|
4 # |
|
5 # colormap(map) sets the current colormap to map. map should be an n row |
|
6 # by 3 column matrix. The columns contain red, green, and blue intensities |
|
7 # respectively. All entries should be between 0 and 1 inclusive. The new |
|
8 # colormap is returned. |
|
9 # |
|
10 # colormap("default") restores the default colormap (a gray scale colormap |
|
11 # with 64 entries). The default colormap is returned. |
|
12 # |
|
13 # colormap with no arguments returns the current colormap. |
|
14 |
|
15 # Author: |
|
16 # Tony Richardson |
|
17 # amr@mpl.ucsd.edu |
|
18 # July 1994 |
559
|
19 |
|
20 global CURRENT_COLOR_MAP |
|
21 |
|
22 cmap_name = "CURRENT_COLOR_MAP"; |
|
23 |
|
24 if(nargin == 1) |
|
25 if(isstr(map)) |
|
26 if(strcmp(map,"default")) |
|
27 CURRENT_COLOR_MAP = gray; |
|
28 else |
|
29 error("invalid argument"); |
|
30 endif |
|
31 else |
|
32 # Set the new color map |
|
33 CURRENT_COLOR_MAP = map; |
|
34 endif |
|
35 elseif(exist(cmap_name) == 0) |
|
36 # If global color map doesn't exist, create the default map. |
|
37 CURRENT_COLOR_MAP = gray; |
|
38 endif |
|
39 |
|
40 # Return current color map. |
|
41 cmap = CURRENT_COLOR_MAP; |
|
42 endfunction |