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 -*- |
7122
|
19 ## @deftypefn {Function File} {} shading (@var{type}) |
|
20 ## @deftypefnx {Function File} {} shading (@var{ax}, @dots{}) |
|
21 ## Set the shading of surface or patch graphic objects. Valid arguments |
|
22 ## for @var{type} are @code{"flat"}, @code{"interp"}, or |
|
23 ## @code{"faceted"}. If @var{ax} is given the shading is applied to |
|
24 ## axis @var{ax} instead of the current axis. |
7109
|
25 ## @end deftypefn |
|
26 |
7110
|
27 ## Author: Kai Habel <kai.habel@gmx.de> |
|
28 |
|
29 function shading (ax, mode) |
7109
|
30 |
|
31 if (nargin == 1) |
|
32 mode = ax; |
7110
|
33 ax = gca (); |
7151
|
34 endif |
7109
|
35 |
7110
|
36 if (nargin != 1 && nargin != 2) |
|
37 print_usage (); |
|
38 endif |
7109
|
39 |
7110
|
40 h1 = findobj (ax, "type", "patch"); |
|
41 h2 = findobj (ax, "type", "surface"); |
|
42 |
|
43 obj = [h1, h2]; |
|
44 |
|
45 for n = 1:numel(obj) |
7109
|
46 h = obj(n); |
7110
|
47 if (strcmp (mode, "flat")) |
|
48 set (h, "facecolor", "flat"); |
|
49 set (h, "edgecolor", "none"); |
|
50 elseif (strcmp (mode, "interp")) |
|
51 set (h, "facecolor", "interp"); |
|
52 set (h, "edgecolor", "none"); |
|
53 elseif (strcmp (mode, "faceted")) |
|
54 set (h, "facecolor", "flat"); |
|
55 set (h, "edgecolor", [0 0 0]); |
7109
|
56 else |
7110
|
57 error ("unknown argument"); |
7109
|
58 endif |
|
59 endfor |
7110
|
60 |
7109
|
61 endfunction |