Mercurial > octave
annotate scripts/image/ocean.m @ 11420:466ba499eff5
Update docstrings for colormap files.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 28 Dec 2010 13:08:23 -0800 |
parents | 2b0cc0b6db61 |
children | fd0a3ac60b0e |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2002, 2005, 2006, |
2 ## 2007 John W. Eaton | |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
559 | 19 |
3381 | 20 ## -*- texinfo -*- |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
21 ## @deftypefn {Function File} {@var{map} =} ocean () |
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{map} =} ocean (@var{n}) |
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
23 ## Create color colormap. This colormap varies from black to white with shades |
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
24 ## of blue. |
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
25 ## The argument @var{n} must be a scalar. |
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
26 ## If unspecified, the length of the current colormap, or 64, is used. |
3373 | 27 ## @end deftypefn |
1024 | 28 |
3202 | 29 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312 | 30 ## Created: July 1994 |
31 ## Adapted-By: jwe | |
1024 | 32 |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
33 function map = ocean (n) |
1024 | 34 |
35 if (nargin == 0) | |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
36 n = rows (colormap); |
1024 | 37 elseif (nargin == 1) |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
38 if (! isscalar (n)) |
1024 | 39 error ("ocean: argument must be a scalar"); |
40 endif | |
41 else | |
6046 | 42 print_usage (); |
559 | 43 endif |
44 | |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
45 cutin = fix (n/3); |
2325 | 46 |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
47 dr = (n - 1) / cutin; |
1024 | 48 |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
49 r = prepad ([0:dr:(n-1)], n)'; |
1024 | 50 |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
51 dg = (n - 1) / (2 * cutin); |
1024 | 52 |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
53 g = prepad([0:dg:(n-1)], n)'; |
1024 | 54 |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
55 b = [0:(n-1)]'; |
559 | 56 |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
57 map = [ r, g, b ] / (n - 1); |
559 | 58 |
59 endfunction | |
9751
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
7017
diff
changeset
|
60 |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
7017
diff
changeset
|
61 %!demo |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
7017
diff
changeset
|
62 %! ## Show the 'ocean' colormap as an image |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
7017
diff
changeset
|
63 %! image (1:64, linspace (0, 1, 64), repmat (1:64, 64, 1)') |
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
7017
diff
changeset
|
64 %! axis ([1, 64, 0, 1], "ticy", "xy") |
11420
466ba499eff5
Update docstrings for colormap files.
Rik <octave@nomad.inbox5.com>
parents:
9751
diff
changeset
|
65 %! colormap (ocean (64)) |
9751
2b0cc0b6db61
Add demos for colormap functions
Soren Hauberg <hauberg@gmail.com>
parents:
7017
diff
changeset
|
66 |