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