8920
|
1 ## Copyright (C) 1999, 2000, 2007, 2009 Kai Habel |
6788
|
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 |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
6788
|
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 |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
6788
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} hsv (@var{n}) |
8543
|
21 ## Create color colormap. This colormap is red through yellow, green, |
|
22 ## cyan, blue, magenta to red. It is obtained by linearly varying the |
|
23 ## hue through all possible values while keeping constant maximum |
|
24 ## saturation and value and is equivalent to |
|
25 ## @code{hsv2rgb ([linspace(0,1,N)', ones(N,2)])}. |
|
26 ## |
|
27 ## The argument @var{n} should be a scalar. If it is omitted, the |
|
28 ## length of the current colormap or 64 is assumed. |
6788
|
29 ## @seealso{colormap} |
|
30 ## @end deftypefn |
|
31 |
|
32 ## Author: Kai Habel <kai.habel@gmx.de> |
|
33 |
|
34 function map = hsv (number) |
|
35 |
|
36 if (nargin == 0) |
|
37 number = rows (colormap); |
|
38 elseif (nargin == 1) |
6791
|
39 if (! isscalar (number)) |
6788
|
40 error ("hsv: argument must be a scalar"); |
|
41 endif |
|
42 else |
|
43 print_usage (); |
|
44 endif |
|
45 |
|
46 if (number == 1) |
|
47 map = [1, 0, 0]; |
|
48 elseif (number > 1) |
|
49 h = linspace (0, 1, number)'; |
|
50 map = hsv2rgb ([h, ones(number, 1), ones(number, 1)]); |
|
51 else |
|
52 map = []; |
|
53 endif |
|
54 |
|
55 endfunction |