6793
|
1 ## Copyright (C) 1999,2000 Kai Habel |
|
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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} flag (@var{n}) |
|
22 ## Create color colormap. This colormap cycles through red, white, blue |
|
23 ## and black. The argument @var{n} should be a scalar. If it |
|
24 ## is omitted, the length of the current colormap or 64 is assumed. |
|
25 ## @seealso{colormap} |
|
26 ## @end deftypefn |
|
27 |
|
28 ## Author: Kai Habel <kai.habel@gmx.de> |
|
29 |
|
30 ## flag(number) gives a colormap consists of red, white, blue and black |
|
31 ## changing with each index |
|
32 |
|
33 function map = flag (number) |
|
34 |
|
35 if (nargin == 0) |
|
36 number = rows (colormap); |
|
37 elseif (nargin == 1) |
|
38 if (! isscalar (number)) |
|
39 error ("flag: argument must be a scalar"); |
|
40 endif |
|
41 else |
|
42 print_usage (); |
|
43 endif |
|
44 |
|
45 p = [1, 0, 0; 1, 1, 1; 0, 0, 1; 0, 0, 0]; |
|
46 if (rem(number,4) == 0) |
|
47 map = kron (ones (number / 4, 1), p); |
|
48 else |
|
49 map = [kron (ones (fix (number / 4), 1), p); p(1:rem (number, 4), :)]; |
|
50 endif |
|
51 |
|
52 endfunction |