1 ## Copyright (C) 2007-2012 David Bateman
3 ## This file is part of Octave.
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.
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.
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/>.
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.
27 ## The optional return value @var{h} is an array of graphics handles to
28 ## the created patch objects.
32 function retval = fill (varargin)
34 [h, varargin] = __plt_get_axis_arg__ ("fill", varargin{:});
37 iargs = __find_patches__ (varargin{:});
43 nextplot = get (h, "nextplot");
44 for i = 1 : length (iargs)
45 if (i > 1 && strncmp (nextplot, "replace", 7))
46 set (h, "nextplot", "add");
48 if (i == length (iargs))
49 args = varargin (iargs(i):end);
51 args = varargin (iargs(i):iargs(i+1)-1);
54 [tmp, fail] = __patch__ (h, args{:});
60 if (strncmp (nextplot, "replace", 7))
61 set (h, "nextplot", nextplot);
63 unwind_protect_cleanup
73 function iargs = __find_patches__ (varargin)
78 if (ischar (varargin{i})
79 && (strcmpi (varargin{i}, "faces")
80 || strcmpi (varargin{i}, "vertices")))
82 elseif (isnumeric (varargin{i}))
88 if (ischar (varargin{i})
89 && (strcmpi (varargin{i}, "faces")
90 || strcmpi (varargin{i}, "vertices")))
92 elseif (isnumeric (varargin{i}))
93 ## Assume its the colorspec
96 elseif (ischar (varargin{i}))
97 colspec = tolower (varargin{i});
98 collen = length (colspec);
100 if (strncmp (colspec, "blue", collen)
101 || strncmp (colspec, "black", collen)
102 || strncmp (colspec, "k", collen)
103 || strncmp (colspec, "black", collen)
104 || strncmp (colspec, "red", collen)
105 || strncmp (colspec, "green", collen)
106 || strncmp (colspec, "yellow", collen)
107 || strncmp (colspec, "magenta", collen)
108 || strncmp (colspec, "cyan", collen)
109 || strncmp (colspec, "white", collen))
124 %! t1 = (1/16:1/8:1)*2*pi;
125 %! t2 = ((1/16:1/8:1) + 1/32)*2*pi;
126 %! x1 = sin (t1) - 0.8;
128 %! x2 = sin (t2) + 0.8;
130 %! h = fill (x1,y1,'r', x2,y2,'g');