comparison scripts/image/hot.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} {} hot (@var{n})
22 ## Create color colormap. This colormap is black through dark red, red,
23 ## orange, yellow to white. 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 = hot (number)
31
32 if (nargin == 0)
33 number = rows (colormap);
34 elseif (nargin == 1)
35 if (! is_scalar (number))
36 error ("hot: argument must be a scalar");
37 endif
38 else
39 print_usage ();
40 endif
41
42 if (number == 1)
43 map = [0, 0, 0];
44 elseif (number > 1)
45 x = linspace (0, 1, number)';
46 r = (x < 2/5) .* (5/2 * x) + (x >= 2/5);
47 g = (x >= 2/5 & x < 4/5) .* (5/2 * x - 1) + (x >= 4/5);
48 b = (x >= 4/5) .* (5*x - 4);
49 map = [r, g, b];
50 else
51 map = [];
52 endif
53
54 endfunction