Mercurial > hg > octave-image
annotate flag.m @ 136:78b9878c50f0 Octave-Forge-2004.11.16
Add new functions
author | pkienzle |
---|---|
date | Tue, 16 Nov 2004 09:18:23 +0000 |
parents | 2adef77b98d0 |
children |
rev | line source |
---|---|
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 if (nargin == 0) | |
40
2adef77b98d0
Remove reference to global variable __current_colormap__; we need to do
pkienzle
parents:
0
diff
changeset
|
34 number = rows (colormap); |
0 | 35 elseif (nargin == 1) |
36 if (! is_scalar (number)) | |
37 error ("flag: argument must be a scalar"); | |
38 endif | |
39 else | |
40 usage ("flag (number)"); | |
41 endif | |
42 | |
43 p = [1, 0, 0; 1, 1, 1; 0, 0, 1; 0, 0, 0]; | |
44 if (rem(number,4) == 0) | |
45 map=kron (ones (number / 4, 1), p); | |
46 else | |
47 map=[kron(ones (fix (number / 4), 1), p); p(1:rem (number, 4), :)]; | |
48 endif | |
49 | |
50 endfunction |