changelog shortlog tags changeset files revisions annotate raw

scripts/plot/shading.m

changeset 10289: 4b124317dc38
parent:eb63fbe60fab
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (42 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 2006, 2007, 2008, 2009 Kai Habel
2##
3## This file is part of Octave.
4##
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
7## the Free Software Foundation; either version 3 of the License, or (at
8## your option) any later version.
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
16## along with Octave; see the file COPYING. If not, see
17## <http://www.gnu.org/licenses/>.
18
19## -*- texinfo -*-
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
24##
25## @table @code
26## @item "flat"
27## Single colored patches with invisible edges.
28##
29## @item "faceted"
30## Single colored patches with visible edges.
31##
32## @item "interp"
33## Color between patch vertices are interpolated and the patch edges are
34## invisible.
35## @end table
36##
37## If @var{ax} is given the shading is applied to axis @var{ax} instead
38## of the current axis.
39## @end deftypefn
40
41## Author: Kai Habel <kai.habel@gmx.de>
42
43function shading (varargin)
44
45 [ax, varargin] = __plt_get_axis_arg__ ("shading", varargin{:});
46
47 if (nargin != 1 && nargin != 2)
48 print_usage ();
49 endif
50
51 mode = varargin{1};
52
53 h1 = findobj (ax, "type", "patch");
54 h2 = findobj (ax, "type", "surface");
55
56 obj = [h1(:); h2(:)];
57
58 for n = 1:numel(obj)
59 h = obj(n);
60 if (strcmpi (mode, "flat"))
61 set (h, "facecolor", "flat");
62 set (h, "edgecolor", "none");
63 elseif (strcmpi (mode, "interp"))
64 set (h, "facecolor", "interp");
65 set (h, "edgecolor", "none");
66 elseif (strcmpi (mode, "faceted"))
67 set (h, "facecolor", "flat");
68 set (h, "edgecolor", [0 0 0]);
69 else
70 error ("unknown argument");
71 endif
72 endfor
73
74endfunction
75
76%!demo
77%! clf
78%! colormap (jet)
79%! sombrero
80%! shading faceted
81%! title('shading "faceted"')
82
83%!demo
84%! sombrero
85%! shading interp
86%! title('shading "interp"')
87
88%!demo
89%! pcolor (peaks ())
90%! shading faceted
91%! title('shading "faceted"')
92
93%!demo
94%! pcolor (peaks ())
95%! shading interp
96%! title('shading "interp"')