Mercurial > hg > octave-lyh
annotate scripts/plot/fill.m @ 12462:e4dbfe3019b1
Use PCRE regular expressions throughout Octave.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 19 Feb 2011 18:21:58 -0800 |
parents | fd0a3ac60b0e |
children | 5f0bb45e615c |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 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{}) |
7020 | 25 ## Create one or more filled patch objects, returning a patch object for each. |
26 ## @end deftypefn | |
27 | |
7216 | 28 function retval = fill (varargin) |
7020 | 29 |
7215 | 30 [h, varargin] = __plt_get_axis_arg__ ("fill", varargin{:}); |
7216 | 31 |
7020 | 32 htmp = []; |
7215 | 33 iargs = __find_patches__ (varargin{:}); |
7216 | 34 |
7215 | 35 oldh = gca (); |
36 unwind_protect | |
37 axes (h); | |
7020 | 38 |
11306
262c365eb71c
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
39 nextplot = get (h, "nextplot"); |
7020 | 40 for i = 1 : length (iargs) |
11325
56c8a00a269f
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11306
diff
changeset
|
41 if (i > 1 && strncmp (nextplot, "replace", 7)) |
56c8a00a269f
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11306
diff
changeset
|
42 set (h, "nextplot", "add"); |
56c8a00a269f
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11306
diff
changeset
|
43 endif |
7020 | 44 if (i == length (iargs)) |
10549 | 45 args = varargin (iargs(i):end); |
7020 | 46 else |
47 args = varargin (iargs(i):iargs(i+1)-1); | |
48 endif | |
7041 | 49 newplot (); |
7215 | 50 [tmp, fail] = __patch__ (h, args{:}); |
7020 | 51 if (fail) |
10549 | 52 print_usage(); |
7020 | 53 endif |
54 htmp (end + 1) = tmp; | |
55 endfor | |
11306
262c365eb71c
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
56 if (strncmp (nextplot, "replace", 7)) |
262c365eb71c
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
57 set (h, "nextplot", nextplot); |
262c365eb71c
fill.m: Allow multiple filled polygons.
Ben Abbott <bpabbott@mac.com>
parents:
11149
diff
changeset
|
58 endif |
7215 | 59 unwind_protect_cleanup |
60 axes (oldh); | |
61 end_unwind_protect | |
62 | |
7020 | 63 if (nargout > 0) |
7216 | 64 retval = htmp; |
7020 | 65 endif |
7215 | 66 |
7020 | 67 endfunction |
68 | |
69 function iargs = __find_patches__ (varargin) | |
70 iargs = []; | |
71 i = 1; | |
72 while (i < nargin) | |
73 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
|
74 if (ischar (varargin{i}) |
10549 | 75 && (strcmpi (varargin{i}, "faces") |
76 || strcmpi (varargin{i}, "vertices"))) | |
7020 | 77 i += 4; |
7208 | 78 elseif (isnumeric (varargin{i})) |
7020 | 79 i += 2; |
80 endif | |
81 | |
82 if (i <= nargin) | |
83 while (true); | |
11149
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
10793
diff
changeset
|
84 if (ischar (varargin{i}) |
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
10793
diff
changeset
|
85 && (strcmpi (varargin{i}, "faces") |
fe3c3dfc07eb
style fix: break lines before && and ||, not after
John W. Eaton <jwe@octave.org>
parents:
10793
diff
changeset
|
86 || strcmpi (varargin{i}, "vertices"))) |
10549 | 87 break; |
88 elseif (isnumeric (varargin{i})) | |
89 ## Assume its the colorspec | |
90 i++; | |
91 break; | |
92 elseif (ischar (varargin{i})) | |
93 colspec = tolower (varargin{i}); | |
94 collen = length (colspec); | |
7020 | 95 |
10549 | 96 if (strncmp (colspec, "blue", collen) |
97 || strncmp (colspec, "black", collen) | |
98 || strncmp (colspec, "k", collen) | |
99 || strncmp (colspec, "black", collen) | |
100 || strncmp (colspec, "red", collen) | |
101 || strncmp (colspec, "green", collen) | |
102 || strncmp (colspec, "yellow", collen) | |
103 || strncmp (colspec, "magenta", collen) | |
104 || strncmp (colspec, "cyan", collen) | |
105 || strncmp (colspec, "white", collen)) | |
106 i++; | |
107 break; | |
108 endif | |
109 else | |
110 i += 2; | |
111 endif | |
7020 | 112 endwhile |
113 endif | |
114 endwhile | |
115 endfunction | |
116 | |
117 %!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
|
118 %! clf |
7020 | 119 %! t1 = (1/16:1/8:1)'*2*pi; |
120 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
121 %! x1 = sin(t1) - 0.8; | |
122 %! y1 = cos(t1); | |
123 %! x2 = sin(t2) + 0.8; | |
124 %! y2 = cos(t2); | |
8243
ec4d9d657b17
Treat line style argument in stairs
David Bateman <dbateman@free.fr>
parents:
8190
diff
changeset
|
125 %! h = fill(x1,y1,'r',x2,y2,'g'); |