Mercurial > hg > octave-nkf
annotate scripts/image/spinmap.m @ 19002:492c56149535 stable rc-3-8-2-1
3.8.2 release candidate 1
* configure.ac (OCTAVE_VERSION): Bump to 3.8.2-rc1.
(OCTAVE_MINOR_VERSION): Bump to 2-rc1.
(OCTAVE_RELEASE_DATE): Set to 2014-06-06.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 06 Jun 2014 11:43:17 -0400 |
parents | d63878346099 |
children | 446c46af4b42 |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
1 ## Copyright (C) 2007-2013 Kai Habel |
7163 | 2 ## |
7164 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
7163 | 6 ## under the terms of the GNU General Public License as published by |
7164 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
7163 | 9 ## |
7164 | 10 ## Octave is distributed in the hope that it will be useful, but |
7163 | 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 | |
7164 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
7163 | 18 |
19 ## -*- texinfo -*- | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
20 ## @deftypefn {Function File} {} spinmap () |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
21 ## @deftypefnx {Function File} {} spinmap (@var{t}) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
22 ## @deftypefnx {Function File} {} spinmap (@var{t}, @var{inc}) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
23 ## @deftypefnx {Function File} {} spinmap ("inf") |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
24 ## Cycle the colormap for @var{t} seconds with a color increment of @var{inc}. |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
25 ## Both parameters are optional. The default cycle time is 5 seconds and the |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
14264
diff
changeset
|
26 ## default increment is 2. If the option @qcode{"inf"} is given then cycle |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
27 ## continuously until @kbd{Control-C} is pressed. |
7164 | 28 ## |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
29 ## When rotating the original color 1 becomes color 2, color 2 becomes |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
30 ## color 3, etc. A positive or negative increment is allowed and a higher |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
31 ## value of @var{inc} will cause faster cycling through the colormap. |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
32 ## @seealso{colormap} |
7163 | 33 ## @end deftypefn |
34 | |
35 ## Author: Kai Habel <kai.habel at gmx.de> | |
36 | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
37 function spinmap (t = 5, inc = 2) |
7163 | 38 |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
39 if (nargin > 2) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
40 print_usage (); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
41 elseif (ischar (t)) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
42 if (strcmpi (t, "inf")) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
43 t = Inf; |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
44 else |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
45 error ('spinmap: time T must be a real scalar or "inf"'); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
46 endif |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
47 elseif (! isscalar (t) || ! isreal (t)) |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
48 error ("spinmap: time T must be a real scalar"); |
7163 | 49 endif |
50 | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
51 cmap = cmap_orig = get (gcf (), "colormap"); |
7163 | 52 |
53 t0 = clock; | |
7164 | 54 while (etime (clock, t0) < t) |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 cmap = shift (cmap, inc, 1); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 set (gcf (), "colormap", cmap); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
57 drawnow (); |
7164 | 58 endwhile |
59 | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
60 set (gcf (), "colormap", cmap_orig); |
7164 | 61 |
62 endfunction | |
63 | |
14264
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
64 |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
65 %!demo |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
66 %! clf; |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
67 %! colormap (rainbow (128)); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
68 %! imagesc (1:8); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
69 %! axis off; |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
70 %! title ("Rotate color bars to the right"); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
71 %! spinmap (3, 1); |
284656167c25
spinmap.m: Revamp function and make Matlab-compatible.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
72 |