comparison extra/tk_octave/rainbow.m @ 0:6b33357c7561 octave-forge

Initial revision
author pkienzle
date Wed, 10 Oct 2001 19:54:49 +0000
parents
children 33df0c93ed95
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} {} hsv (@var{n})
19 ## Create color colormap.
20 ## (red through yellow, green, cyan,blue,magenta to red)
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 ## 2001-09-13 Paul Kienzle <pkienzle@users.sf.net>
29 ## * renamed to rainbow for use with tk_octave
30 ## * remove reference to __current_color_map__
31
32 function map = rainbow (number)
33
34 if (nargin == 0)
35 number = length(colormap);
36 elseif (nargin == 1)
37 if (! is_scalar (number))
38 error ("hsv: argument must be a scalar");
39 endif
40 else
41 usage ("hsv (number)");
42 endif
43
44 if (number == 1)
45 map = [1, 0, 0];
46 elseif (number > 1)
47 h = linspace (0, 1, number)';
48 map = hsv2rgb ([h, ones(number, 1), ones(number, 1)]);
49 else
50 map = [];
51 endif
52
53 endfunction