Mercurial > hg > octave-lyh
annotate scripts/plot/patch.m @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | a013ff655ca4 |
children | 22ae6b3411a7 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2005, 2007, 2008, 2009 John W. Eaton |
6807 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6807 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6807 | 18 |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} patch () | |
21 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}) | |
22 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}, @var{opts}) | |
7020 | 23 ## @deftypefnx {Function File} {} patch ('Faces', @var{f}, 'Vertices', @var{v}, @dots{}) |
24 ## @deftypefnx {Function File} {} patch (@dots{}, @var{prop}, @var{val}) | |
6988 | 25 ## @deftypefnx {Function File} {} patch (@var{h}, @dots{}) |
7650 | 26 ## @deftypefnx {Function File} {@var{h} =} patch (@dots{}) |
6895 | 27 ## Create patch object from @var{x} and @var{y} with color @var{c} and |
28 ## insert in the current axes object. Return handle to patch object. | |
29 ## | |
30 ## For a uniform colored patch, @var{c} can be given as an RGB vector, | |
31 ## scalar value referring to the current colormap, or string value (for | |
32 ## example, "r" or "red"). | |
6807 | 33 ## @end deftypefn |
34 | |
35 ## Author: jwe | |
36 | |
7216 | 37 function retval = patch (varargin) |
6807 | 38 |
7215 | 39 [h, varargin] = __plt_get_axis_arg__ ("patch", varargin{:}); |
7216 | 40 |
7215 | 41 oldh = gca (); |
7216 | 42 |
7215 | 43 unwind_protect |
44 axes (h); | |
45 [tmp, fail] = __patch__ (h, varargin{:}); | |
46 unwind_protect_cleanup | |
47 axes (oldh); | |
48 end_unwind_protect | |
7020 | 49 |
50 if (fail) | |
51 print_usage (); | |
6988 | 52 endif |
6807 | 53 |
54 if (nargout > 0) | |
7216 | 55 retval = tmp; |
6807 | 56 endif |
57 | |
58 endfunction | |
7020 | 59 |
60 %!demo | |
61 %! ## Patches with same number of vertices | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
62 %! clf |
7020 | 63 %! t1 = (1/16:1/8:1)'*2*pi; |
64 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
65 %! x1 = sin(t1) - 0.8; | |
66 %! y1 = cos(t1); | |
67 %! x2 = sin(t2) + 0.8; | |
68 %! y2 = cos(t2); | |
69 %! patch([x1,x2],[y1,y2],'r'); | |
70 | |
71 %!demo | |
72 %! ## Unclosed patch | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
73 %! clf |
7020 | 74 %! t1 = (1/16:1/8:1)'*2*pi; |
75 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
76 %! x1 = sin(t1) - 0.8; | |
77 %! y1 = cos(t1); | |
78 %! x2 = sin(t2) + 0.8; | |
79 %! y2 = cos(t2); | |
80 %! patch([[x1;NaN(8,1)],x2],[[y1;NaN(8,1)],y2],'r'); | |
81 | |
82 %!demo | |
83 %! ## Specify vertices and faces separately | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
84 %! clf |
7020 | 85 %! t1 = (1/16:1/8:1)'*2*pi; |
86 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
87 %! x1 = sin(t1) - 0.8; | |
88 %! y1 = cos(t1); | |
89 %! x2 = sin(t2) + 0.8; | |
90 %! y2 = cos(t2); | |
91 %! vert = [x1, y1; x2, y2]; | |
92 %! fac = [1:8,NaN(1,8);9:24]; | |
93 %! patch('Faces',fac,'Vertices',vert,'FaceColor','r'); | |
94 | |
95 %!demo | |
96 %! ## Property change on multiple patches | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
97 %! clf |
7020 | 98 %! t1 = (1/16:1/8:1)'*2*pi; |
99 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
100 %! x1 = sin(t1) - 0.8; | |
101 %! y1 = cos(t1); | |
102 %! x2 = sin(t2) + 0.8; | |
103 %! y2 = cos(t2); | |
104 %! h = patch([x1,x2],[y1,y2],cat (3,[0,0],[1,0],[0,1])); | |
105 %! pause (1); | |
106 %! set (h, 'FaceColor', 'r'); |