2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
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. |
2313
|
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/>. |
559
|
18 |
3381
|
19 ## -*- texinfo -*- |
3373
|
20 ## @deftypefn {Function File} {} ocean (@var{n}) |
|
21 ## Create color colormap. The argument @var{n} should be a scalar. If it |
6791
|
22 ## is omitted, the length of the current colormap or 64 is assumed. |
3373
|
23 ## @end deftypefn |
1024
|
24 |
3202
|
25 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312
|
26 ## Created: July 1994 |
|
27 ## Adapted-By: jwe |
1024
|
28 |
2312
|
29 function map = ocean (number) |
1024
|
30 |
|
31 if (nargin == 0) |
6791
|
32 number = rows (colormap); |
1024
|
33 elseif (nargin == 1) |
4030
|
34 if (! isscalar (number)) |
1024
|
35 error ("ocean: argument must be a scalar"); |
|
36 endif |
|
37 else |
6046
|
38 print_usage (); |
559
|
39 endif |
|
40 |
1024
|
41 cutin = fix (number/3); |
2325
|
42 |
1024
|
43 dr = (number - 1) / cutin; |
|
44 |
|
45 r = prepad ([0:dr:(number-1)], number)'; |
|
46 |
|
47 dg = (number - 1) / (2 * cutin); |
|
48 |
|
49 g = prepad([0:dg:(number-1)], number)'; |
|
50 |
559
|
51 b = [0:(number-1)]'; |
|
52 |
6788
|
53 map = [ r, g, b ] / (number - 1); |
559
|
54 |
|
55 endfunction |