Mercurial > hg > octave-lyh
annotate scripts/plot/fill.m @ 14138:72c96de7a403 stable
maint: update copyright notices for 2012
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 02 Jan 2012 14:25:41 -0500 |
parents | 5f0bb45e615c |
children | fe65588c31b8 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14001
diff
changeset
|
1 ## Copyright (C) 2007-2012 David Bateman |
7020 | 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 -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {} fill (@var{x}, @var{y}, @var{c}) |
7020 | 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{}) | |
7650 | 24 ## @deftypefnx {Function File} {@var{h} =} fill (@dots{}) |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
25 ## Create one or more filled patch objects. |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
26 ## |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
27 ## The optional return value @var{h} is an array of graphics handles to |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
28 ## the created patch objects. |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
29 ## @seealso{patch} |
7020 | 30 ## @end deftypefn |
31 | |
7216 | 32 function retval = fill (varargin) |
7020 | 33 |
7215 | 34 [h, varargin] = __plt_get_axis_arg__ ("fill", varargin{:}); |
7216 | 35 |
7020 | 36 htmp = []; |
7215 | 37 iargs = __find_patches__ (varargin{:}); |
7216 | 38 |
7215 | 39 oldh = gca (); |
40 unwind_protect | |
41 axes (h); | |
7020 | 42 |
11306
262c365eb71c
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
43 nextplot = get (h, "nextplot"); |
7020 | 44 for i = 1 : length (iargs) |
11325
56c8a00a269f
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11306
diff
changeset
|
45 if (i > 1 && strncmp (nextplot, "replace", 7)) |
56c8a00a269f
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11306
diff
changeset
|
46 set (h, "nextplot", "add"); |
56c8a00a269f
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11306
diff
changeset
|
47 endif |
7020 | 48 if (i == length (iargs)) |
10549 | 49 args = varargin (iargs(i):end); |
7020 | 50 else |
51 args = varargin (iargs(i):iargs(i+1)-1); | |
52 endif | |
7041 | 53 newplot (); |
7215 | 54 [tmp, fail] = __patch__ (h, args{:}); |
7020 | 55 if (fail) |
10549 | 56 print_usage(); |
7020 | 57 endif |
58 htmp (end + 1) = tmp; | |
59 endfor | |
11306
262c365eb71c
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
60 if (strncmp (nextplot, "replace", 7)) |
262c365eb71c
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
61 set (h, "nextplot", nextplot); |
262c365eb71c
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
62 endif |
7215 | 63 unwind_protect_cleanup |
64 axes (oldh); | |
65 end_unwind_protect | |
66 | |
7020 | 67 if (nargout > 0) |
7216 | 68 retval = htmp; |
7020 | 69 endif |
7215 | 70 |
7020 | 71 endfunction |
72 | |
73 function iargs = __find_patches__ (varargin) | |
74 iargs = []; | |
75 i = 1; | |
76 while (i < nargin) | |
77 iargs (end + 1) = i; | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
78 if (ischar (varargin{i}) |
10549 | 79 && (strcmpi (varargin{i}, "faces") |
80 || strcmpi (varargin{i}, "vertices"))) | |
7020 | 81 i += 4; |
7208 | 82 elseif (isnumeric (varargin{i})) |
7020 | 83 i += 2; |
84 endif | |
85 | |
86 if (i <= nargin) | |
87 while (true); | |
11149
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
10793
diff
changeset
|
88 if (ischar (varargin{i}) |
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
10793
diff
changeset
|
89 && (strcmpi (varargin{i}, "faces") |
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
10793
diff
changeset
|
90 || strcmpi (varargin{i}, "vertices"))) |
10549 | 91 break; |
92 elseif (isnumeric (varargin{i})) | |
93 ## Assume its the colorspec | |
94 i++; | |
95 break; | |
96 elseif (ischar (varargin{i})) | |
97 colspec = tolower (varargin{i}); | |
98 collen = length (colspec); | |
7020 | 99 |
10549 | 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)) | |
110 i++; | |
111 break; | |
112 endif | |
113 else | |
114 i += 2; | |
115 endif | |
7020 | 116 endwhile |
117 endif | |
118 endwhile | |
119 endfunction | |
120 | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
121 |
7020 | 122 %!demo |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
8243
diff
changeset
|
123 %! clf |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
124 %! t1 = (1/16:1/8:1)*2*pi; |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
125 %! t2 = ((1/16:1/8:1) + 1/32)*2*pi; |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
126 %! x1 = sin (t1) - 0.8; |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
127 %! y1 = cos (t1); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
128 %! x2 = sin (t2) + 0.8; |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
129 %! y2 = cos (t2); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
130 %! h = fill (x1,y1,'r', x2,y2,'g'); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
131 |