Mercurial > hg > octave-lyh
annotate scripts/plot/shading.m @ 8166:4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Tue, 30 Sep 2008 16:09:09 -0400 |
parents | f8514786c490 |
children | 73d6b71788c0 |
rev | line source |
---|---|
7110 | 1 ## Copyright (C) 2006, 2007 Kai Habel |
7109 | 2 ## |
7164 | 3 ## This file is part of Octave. |
4 ## | |
7109 | 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 | |
7164 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
7109 | 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 | |
7164 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
7109 | 18 |
19 ## -*- texinfo -*- | |
7122 | 20 ## @deftypefn {Function File} {} shading (@var{type}) |
21 ## @deftypefnx {Function File} {} shading (@var{ax}, @dots{}) | |
22 ## Set the shading of surface or patch graphic objects. Valid arguments | |
7978
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
23 ## for @var{type} are |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
24 ## |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
25 ## @table @code |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
26 ## @item "flat" |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
27 ## Single colored patches with invisible edges. |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
28 ## |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
29 ## @item "faceted" |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
30 ## Single colored patches with visible edges. |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
31 ## |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
32 ## @item "interp" |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
33 ## Color between patch vertices are interpolated and the patch edges are |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
34 ## invisible. |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
35 ## @end table |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
36 ## |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
37 ## If @var{ax} is given the shading is applied to axis @var{ax} instead |
f8514786c490
Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents:
7249
diff
changeset
|
38 ## of the current axis. |
7109 | 39 ## @end deftypefn |
40 | |
7110 | 41 ## Author: Kai Habel <kai.habel@gmx.de> |
42 | |
7249 | 43 ## PKG_ADD: mark_as_command shading |
7109 | 44 |
7249 | 45 function shading (varargin) |
46 | |
47 [ax, varargin] = __plt_get_axis_arg__ ("shading", varargin{:}); | |
7109 | 48 |
7110 | 49 if (nargin != 1 && nargin != 2) |
50 print_usage (); | |
51 endif | |
7109 | 52 |
7249 | 53 mode = varargin{1}; |
54 | |
7110 | 55 h1 = findobj (ax, "type", "patch"); |
56 h2 = findobj (ax, "type", "surface"); | |
57 | |
7249 | 58 obj = [h1(:); h2(:)]; |
7110 | 59 |
60 for n = 1:numel(obj) | |
7109 | 61 h = obj(n); |
7110 | 62 if (strcmp (mode, "flat")) |
63 set (h, "facecolor", "flat"); | |
64 set (h, "edgecolor", "none"); | |
65 elseif (strcmp (mode, "interp")) | |
66 set (h, "facecolor", "interp"); | |
67 set (h, "edgecolor", "none"); | |
68 elseif (strcmp (mode, "faceted")) | |
69 set (h, "facecolor", "flat"); | |
70 set (h, "edgecolor", [0 0 0]); | |
7109 | 71 else |
7110 | 72 error ("unknown argument"); |
7109 | 73 endif |
74 endfor | |
7110 | 75 |
7109 | 76 endfunction |
8166
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
77 |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
78 %!demo |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
79 %! figure(1); clf |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
80 %! sombrero |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
81 %! shading faceted |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
82 %! title('shading "faceted"') |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
83 %! figure(2); clf |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
84 %! sombrero |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
85 %! shading interp |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
86 %! title('shading "interp"') |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
87 %! figure (3); clf |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
88 %! pcolor (peaks ()) |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
89 %! shading faceted |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
90 %! title('shading "faceted"') |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
91 %! figure (4); clf |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
92 %! pcolor (peaks ()) |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
93 %! shading interp |
4024fc815f8d
__go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents:
7978
diff
changeset
|
94 %! title('shading "interp"') |