comparison main/image/spring.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} {} spring (@var{n})
19 ## Create color colormap.
20 ## (magenta to yellow)
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 = spring (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 ("spring: argument must be a scalar");
40 endif
41 else
42 usage ("spring (number)");
43 endif
44
45 if (number == 1)
46 map = [1, 0, 1];
47 elseif (number > 1)
48 r = ones (number, 1);
49 g = (0:number - 1)' ./ (number - 1);
50 b = 1 - g;
51 map = [r, g, b];
52 else
53 map = [];
54 endif
55
56 endfunction