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