0
|
1 ## Copyright (C) 1999,2000 Kai Habel |
|
2 ## |
|
3 ## This program is free software; you can redistribute it and/or modify |
|
4 ## it under the terms of the GNU General Public License as published by |
|
5 ## the Free Software Foundation; either version 2 of the License, or |
|
6 ## (at your option) any later version. |
|
7 ## |
|
8 ## This program is distributed in the hope that it will be useful, |
|
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 ## GNU General Public License for more details. |
|
12 ## |
|
13 ## You should have received a copy of the GNU General Public License |
|
14 ## along with this program; if not, write to the Free Software |
|
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
16 |
|
17 ## -*- texinfo -*- |
|
18 ## @deftypefn {Function File} {} flag (@var{n}) |
|
19 ## Create color colormap. |
|
20 ## (cycling through red, white, blue and black) |
|
21 ## The argument @var{n} should be a scalar. If it |
|
22 ## is omitted, the length of the current colormap or 64 is assumed. |
|
23 ## @end deftypefn |
|
24 ## @seealso{colormap} |
|
25 |
|
26 ## Author: Kai Habel <kai.habel@gmx.de> |
|
27 |
|
28 ## flag(number) gives a colormap consists of red, white, blue and black |
|
29 ## changing with each index |
|
30 |
|
31 function map = flag (number) |
|
32 |
|
33 global __current_color_map__ |
|
34 |
|
35 if (nargin == 0) |
|
36 if exist ("__current_color_map__") |
|
37 number = rows (__current_color_map__); |
|
38 else |
|
39 number = 64; |
|
40 endif |
|
41 elseif (nargin == 1) |
|
42 if (! is_scalar (number)) |
|
43 error ("flag: argument must be a scalar"); |
|
44 endif |
|
45 else |
|
46 usage ("flag (number)"); |
|
47 endif |
|
48 |
|
49 p = [1, 0, 0; 1, 1, 1; 0, 0, 1; 0, 0, 0]; |
|
50 if (rem(number,4) == 0) |
|
51 map=kron (ones (number / 4, 1), p); |
|
52 else |
|
53 map=[kron(ones (fix (number / 4), 1), p); p(1:rem (number, 4), :)]; |
|
54 endif |
|
55 |
|
56 endfunction |