7110
|
1 ## Copyright (C) 2006, 2007 Kai Habel |
7109
|
2 ## |
|
3 ## Octave is free software; you can redistribute it and/or modify it |
|
4 ## under the terms of the GNU General Public License as published by |
|
5 ## the Free Software Foundation; either version 2, or (at your option) |
|
6 ## any later version. |
|
7 ## |
|
8 ## Octave is distributed in the hope that it will be useful, but |
|
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 ## General Public License for more details. |
|
12 ## |
|
13 ## You should have received a copy of the GNU General Public License |
|
14 ## along with Octave; see the file COPYING. If not, write to the Free |
|
15 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
16 ## 02110-1301, USA. |
|
17 |
|
18 ## -*- texinfo -*- |
|
19 ## @deftypefn {Function File} shading (@var{type}) |
|
20 ## @deftypefnx {Function File} shading (@var{ax}, ...) |
|
21 ## |
|
22 ## Sets the shading of surface or patch graphic objects. Valid arguments for |
|
23 ## @var{type} are "flat", "interp", or "faceted". |
|
24 ## If @var{ax} is given the shading is applied to axis @var{ax} instead of the |
|
25 ## current axis. |
|
26 ## |
|
27 ## @example |
|
28 ## shading ("interp") |
|
29 ## @end example |
|
30 ## |
|
31 ## @end deftypefn |
|
32 |
7110
|
33 ## Author: Kai Habel <kai.habel@gmx.de> |
|
34 |
|
35 function shading (ax, mode) |
7109
|
36 |
|
37 if (nargin == 1) |
|
38 mode = ax; |
7110
|
39 ax = gca (); |
7109
|
40 end |
|
41 |
7110
|
42 if (nargin != 1 && nargin != 2) |
|
43 print_usage (); |
|
44 endif |
7109
|
45 |
7110
|
46 h1 = findobj (ax, "type", "patch"); |
|
47 h2 = findobj (ax, "type", "surface"); |
|
48 |
|
49 obj = [h1, h2]; |
|
50 |
|
51 for n = 1:numel(obj) |
7109
|
52 h = obj(n); |
7110
|
53 if (strcmp (mode, "flat")) |
|
54 set (h, "facecolor", "flat"); |
|
55 set (h, "edgecolor", "none"); |
|
56 elseif (strcmp (mode, "interp")) |
|
57 set (h, "facecolor", "interp"); |
|
58 set (h, "edgecolor", "none"); |
|
59 elseif (strcmp (mode, "faceted")) |
|
60 set (h, "facecolor", "flat"); |
|
61 set (h, "edgecolor", [0 0 0]); |
7109
|
62 else |
7110
|
63 error ("unknown argument"); |
7109
|
64 endif |
|
65 endfor |
7110
|
66 |
7109
|
67 endfunction |