Mercurial > hg > octave-lyh
comparison scripts/image/hsv.m @ 6788:c81a0f3f5a82
[project @ 2007-07-23 22:05:29 by dbateman]
author | dbateman |
---|---|
date | Mon, 23 Jul 2007 22:05:30 +0000 |
parents | |
children | be31a048c449 |
comparison
equal
deleted
inserted
replaced
6787:963a19576024 | 6788:c81a0f3f5a82 |
---|---|
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} {} hsv (@var{n}) | |
22 ## Create color colormap. This colormap is red through yellow, green, cyan, | |
23 ## blue, magenta to red. 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 function map = hsv (number) | |
31 | |
32 if (nargin == 0) | |
33 number = rows (colormap); | |
34 elseif (nargin == 1) | |
35 if (! is_scalar (number)) | |
36 error ("hsv: argument must be a scalar"); | |
37 endif | |
38 else | |
39 print_usage (); | |
40 endif | |
41 | |
42 if (number == 1) | |
43 map = [1, 0, 0]; | |
44 elseif (number > 1) | |
45 h = linspace (0, 1, number)'; | |
46 map = hsv2rgb ([h, ones(number, 1), ones(number, 1)]); | |
47 else | |
48 map = []; | |
49 endif | |
50 | |
51 endfunction |