Mercurial > forge
comparison main/image/prism.m @ 0:6b33357c7561 octave-forge
Initial revision
author | pkienzle |
---|---|
date | Wed, 10 Oct 2001 19:54:49 +0000 |
parents | |
children | 7b93ae40a2f5 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6b33357c7561 |
---|---|
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} {} prism (@var{n}) | |
19 ## Create color colormap. | |
20 ## (cycling trough red, orange, yellow, green, blue and violet) | |
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 function map = prism (number) | |
29 global __current_color_map__ | |
30 | |
31 if (nargin == 0) | |
32 if exist("__current_color_map__") | |
33 number = rows (__current_color_map__); | |
34 else | |
35 number = 64; | |
36 endif | |
37 elseif (nargin == 1) | |
38 if (! is_scalar (number)) | |
39 error ("prism: argument must be a scalar"); | |
40 endif | |
41 else | |
42 usage ("prism (number)"); | |
43 endif | |
44 | |
45 p = [1, 0, 0; 1, 1/2, 0; 1, 1, 0; 0, 1, 0; 0, 0, 1; 2/3, 0, 1]; | |
46 | |
47 if (rem (number, 6) == 0) | |
48 map = kron(ones (fix (number / 6), 1), p); | |
49 else | |
50 map = [kron(ones (fix (number / 6), 1), p); p(1:rem (number, 6), :)]; | |
51 endif | |
52 | |
53 endfunction |