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