7020
|
1 ## Copyright (C) 2007 David Bateman |
|
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} {} fill (@var{x}, @var{y}, @var{c}) |
|
21 ## @deftypefnx {Function File} {} fill (@var{x1}, @var{y1}, @var{c1}, @var{x2}, @var{y2}, @var{c2}) |
|
22 ## @deftypefnx {Function File} {} fill (@dots{}, @var{prop}, @var{val}) |
|
23 ## @deftypefnx {Function File} {} fill (@var{h}, @dots{}) |
|
24 ## @deftypefnx {Function File} {@var{h} = } fill (@dots{}) |
|
25 ## Create one or more filled patch objects, returning a patch object for each. |
|
26 ## @end deftypefn |
|
27 |
|
28 function h = fill (varargin) |
|
29 |
7215
|
30 [h, varargin] = __plt_get_axis_arg__ ("fill", varargin{:}); |
7020
|
31 htmp = []; |
7215
|
32 iargs = __find_patches__ (varargin{:}); |
|
33 oldh = gca (); |
|
34 unwind_protect |
|
35 axes (h); |
7020
|
36 |
|
37 for i = 1 : length (iargs) |
|
38 if (i == length (iargs)) |
|
39 args = varargin (iargs(i):end); |
|
40 else |
|
41 args = varargin (iargs(i):iargs(i+1)-1); |
|
42 endif |
7041
|
43 newplot (); |
7215
|
44 [tmp, fail] = __patch__ (h, args{:}); |
7020
|
45 if (fail) |
|
46 print_usage(); |
|
47 endif |
|
48 htmp (end + 1) = tmp; |
|
49 endfor |
7215
|
50 unwind_protect_cleanup |
|
51 axes (oldh); |
|
52 end_unwind_protect |
|
53 |
7020
|
54 if (nargout > 0) |
|
55 h = htmp; |
|
56 endif |
7215
|
57 |
7020
|
58 endfunction |
|
59 |
|
60 function iargs = __find_patches__ (varargin) |
|
61 iargs = []; |
|
62 i = 1; |
|
63 while (i < nargin) |
|
64 iargs (end + 1) = i; |
7208
|
65 if (ischar (varargin{i}) && (strcmp (tolower (varargin{i}), "faces") || |
7020
|
66 strcmp (tolower (varargin{i}), "vertices"))) |
|
67 i += 4; |
7208
|
68 elseif (isnumeric (varargin{i})) |
7020
|
69 i += 2; |
|
70 endif |
|
71 |
|
72 if (i <= nargin) |
|
73 while (true); |
7208
|
74 if (ischar (varargin{i}) && |
7020
|
75 (strcmp (tolower (varargin{i}), "faces") || |
|
76 strcmp (tolower (varargin{i}), "vertices"))) |
|
77 break; |
7208
|
78 elseif (isnumeric (varargin{i})) |
7020
|
79 ## Assume its the colorspec |
|
80 i++; |
|
81 break; |
7208
|
82 elseif (ischar (varargin{i})) |
|
83 colspec = tolower (varargin{i}); |
7020
|
84 collen = length (colspec); |
|
85 |
|
86 if (strncmp (colspec, "blue", collen) || |
|
87 strncmp (colspec, "black", collen) || |
|
88 strncmp (colspec, "k", collen) || |
|
89 strncmp (colspec, "black", collen) || |
|
90 strncmp (colspec, "red", collen) || |
|
91 strncmp (colspec, "green", collen) || |
|
92 strncmp (colspec, "yellow", collen) || |
|
93 strncmp (colspec, "magenta", collen) || |
|
94 strncmp (colspec, "cyan", collen) || |
|
95 strncmp (colspec, "white", collen)) |
|
96 i++; |
|
97 break; |
|
98 endif |
|
99 else |
|
100 i += 2; |
|
101 endif |
|
102 endwhile |
|
103 endif |
|
104 endwhile |
|
105 endfunction |
|
106 |
|
107 %!demo |
|
108 %! close all; |
|
109 %! t1 = (1/16:1/8:1)'*2*pi; |
|
110 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; |
|
111 %! x1 = sin(t1) - 0.8; |
|
112 %! y1 = cos(t1); |
|
113 %! x2 = sin(t2) + 0.8; |
|
114 %! y2 = cos(t2); |
|
115 %! h = fill(x1,y1,'r',x2,y2,'g') |