Mercurial > hg > octave-nkf
annotate scripts/plot/draw/fill.m @ 20737:2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
* mex.cc (mxIsFromGlobalWS): Call mexErrMsgTxt rather than abort() in function.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 29 Sep 2015 12:00:11 -0700 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
1 ## Copyright (C) 2007-2015 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}) | |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
23 ## @deftypefnx {Function File} {} fill (@var{hax}, @dots{}) |
7650 | 24 ## @deftypefnx {Function File} {@var{h} =} fill (@dots{}) |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
25 ## Create one or more filled 2-D polygons. |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
26 ## |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
27 ## The inputs @var{x} and @var{y} are the coordinates of the polygon vertices. |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
28 ## If the inputs are matrices then the rows represent different vertices and |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17075
diff
changeset
|
29 ## each column produces a different polygon. @code{fill} will close any open |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
30 ## polygons before plotting. |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
31 ## |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
32 ## The input @var{c} determines the color of the polygon. The simplest form |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
33 ## is a single color specification such as a @code{plot} format or an |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
34 ## RGB-triple. In this case the polygon(s) will have one unique color. If |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
35 ## @var{c} is a vector or matrix then the color data is first scaled using |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
36 ## @code{caxis} and then indexed into the current colormap. A row vector will |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
37 ## color each polygon (a column from matrices @var{x} and @var{y}) with a |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
38 ## single computed color. A matrix @var{c} of the same size as @var{x} and |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
39 ## @var{y} will compute the color of each vertex and then interpolate the face |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
40 ## color between the vertices. |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
41 ## |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
42 ## Multiple property/value pairs for the underlying patch object may be |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
43 ## specified, but they must appear in pairs. |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
44 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17075
diff
changeset
|
45 ## If the first argument @var{hax} is an axes handle, then plot into this axis, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17075
diff
changeset
|
46 ## rather than the current axes returned by @code{gca}. |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
47 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17075
diff
changeset
|
48 ## The optional return value @var{h} is a vector of graphics handles to |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
49 ## the created patch objects. |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
50 ## |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
51 ## Example: red square |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
52 ## |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
53 ## @example |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
54 ## @group |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
55 ## vertices = [0 0 |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
56 ## 1 0 |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
57 ## 1 1 |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
58 ## 0 1]; |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
59 ## fill (vertices(:,1), vertices(:,2), "r"); |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
60 ## axis ([-0.5 1.5, -0.5 1.5]) |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
61 ## axis equal |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
62 ## @end group |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
63 ## @end example |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
64 ## |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
65 ## @seealso{patch, caxis, colormap} |
7020 | 66 ## @end deftypefn |
67 | |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
68 function h = fill (varargin) |
7020 | 69 |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
70 [hax, varargin] = __plt_get_axis_arg__ ("fill", varargin{:}); |
7216 | 71 |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
72 hlist = []; |
7215 | 73 iargs = __find_patches__ (varargin{:}); |
7216 | 74 |
17609
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
75 opts = {}; |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
76 if (numel (varargin) > iargs(end) + 2) |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
77 opts = varargin(iargs(end)+3 : end); |
17609
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
78 endif |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
79 |
17609
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
80 if (! all (cellfun (@(x) iscolorspec (x), varargin(iargs + 2)))) |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
81 print_usage (); |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
82 endif |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
83 |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
84 oldfig = []; |
17301
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17211
diff
changeset
|
85 if (! isempty (hax)) |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
86 oldfig = get (0, "currentfigure"); |
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
87 endif |
7215 | 88 unwind_protect |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
89 hax = newplot (hax); |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
90 old_nxtplt = get (hax, "nextplot"); |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
91 unwind_protect |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
92 set (hax, "nextplot", "add"); |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
93 |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
94 for i = 1 : length (iargs) |
18404
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
95 x = varargin{iargs(i)}; |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
96 y = varargin{iargs(i) + 1}; |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
97 cdata = varargin{iargs(i) + 2}; |
18404
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
98 |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
99 if (! size_equal (x,y)) |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
100 if (iscolumn (y) && rows (y) == rows (x)) |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
101 y = repmat (y, [1, columns(x)]); |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
102 elseif (iscolumn (x) && rows (x) == rows (y)) |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
103 x = repmat (x, [1, columns(y)]); |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
104 else |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
105 error ("fill: X annd Y must have same number of rows"); |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
106 endif |
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
107 endif |
18072
b4b5ee91561a
fill.m: replicate cdata to match size of data for Matlab compatibility (bug #40777).
Rik <rik@octave.org>
parents:
18039
diff
changeset
|
108 ## For Matlab compatibility, replicate cdata to match size of data |
18403
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
109 if (iscolumn (cdata) && ! ischar (cdata)) |
18404
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
110 sz = size (x); |
18072
b4b5ee91561a
fill.m: replicate cdata to match size of data for Matlab compatibility (bug #40777).
Rik <rik@octave.org>
parents:
18039
diff
changeset
|
111 if (all (sz > 1)) |
b4b5ee91561a
fill.m: replicate cdata to match size of data for Matlab compatibility (bug #40777).
Rik <rik@octave.org>
parents:
18039
diff
changeset
|
112 cdata = repmat (cdata, [1, sz(2)]); |
b4b5ee91561a
fill.m: replicate cdata to match size of data for Matlab compatibility (bug #40777).
Rik <rik@octave.org>
parents:
18039
diff
changeset
|
113 endif |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
114 endif |
17609
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
115 |
18404
15487cae60a3
fill.m: Replicate X or Y vector input to match size of X or Y matrix input.
Rik <rik@octave.org>
parents:
18403
diff
changeset
|
116 [htmp, fail] = __patch__ (hax, x, y, cdata, opts{:}); |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
117 if (fail) |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
118 print_usage (); |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
119 endif |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
120 |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
121 hlist(end+1, 1) = htmp; |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
122 endfor |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
123 |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
124 unwind_protect_cleanup |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
125 if (strcmp (old_nxtplt, "replace")) |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
126 set (hax, "nextplot", old_nxtplt); |
7020 | 127 endif |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
128 end_unwind_protect |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
129 |
7215 | 130 unwind_protect_cleanup |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
131 if (! isempty (oldfig)) |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
132 set (0, "currentfigure", oldfig); |
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
133 endif |
7215 | 134 end_unwind_protect |
135 | |
7020 | 136 if (nargout > 0) |
17075
806f48d8a577
fill.m, shading.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents:
14237
diff
changeset
|
137 h = hlist; |
7020 | 138 endif |
7215 | 139 |
7020 | 140 endfunction |
141 | |
142 function iargs = __find_patches__ (varargin) | |
17609
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
143 iargs = 1:3:nargin; |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
144 optidx = find (! cellfun (@isnumeric, varargin(iargs)), 1); |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
145 iargs(optidx:end) = []; |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
146 endfunction |
7020 | 147 |
17609
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
148 function retval = iscolorspec (arg) |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
149 retval = false; |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
150 if (ischar (arg)) |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
151 persistent colors = {"y", "yellow", "r", "red", "m", "magenta", ... |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
152 "c", "cyan", "g", "green", "b", "blue", ... |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
153 "w", "white", "k", "black"}; |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
154 if (any (strcmpi (arg, colors))) |
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
155 retval = true; |
7020 | 156 endif |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
157 elseif (isnumeric (arg)) |
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
158 ## Assume any numeric argument is correctly formatted cdata. |
18039
8e7d2ee1254d
fill.m: Fix incorrect face coloring when using RGB triple (bug #40732).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
159 ## Let patch worry about the multple different input formats. |
17610
3f8b3588a9f0
fill.m: Properly color faces based on orientation of cdata vector.
Rik <rik@octave.org>
parents:
17609
diff
changeset
|
160 retval = true; |
17609
ec31ca0a5812
fill.m: Improve input validation to avoid endless loops (bug #38927).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17572
diff
changeset
|
161 endif |
7020 | 162 endfunction |
163 | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
164 |
7020 | 165 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14230
diff
changeset
|
166 %! clf; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14230
diff
changeset
|
167 %! t1 = (1/16:1/8:1) * 2*pi; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14230
diff
changeset
|
168 %! t2 = ((1/16:1/8:1) + 1/32) * 2*pi; |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
169 %! 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
|
170 %! 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
|
171 %! 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
|
172 %! 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
|
173 %! h = fill (x1,y1,'r', x2,y2,'g'); |
18405 | 174 %! title ({'fill() function'; 'cdata specified with string'}); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
175 |
18405 | 176 %!demo |
177 %! clf; | |
178 %! t1 = (1/16:1/8:1) * 2*pi; | |
179 %! t2 = ((1/16:1/8:1) + 1/32) * 2*pi; | |
180 %! x1 = sin (t1) - 0.8; | |
181 %! y1 = cos (t1); | |
182 %! x2 = sin (t2) + 0.8; | |
183 %! y2 = cos (t2); | |
184 %! h = fill (x1,y1,1, x2,y2,2); | |
185 %! title ({'fill() function'; 'cdata = row vector produces FaceColor = "flat"'}); | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
186 |
18403
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
187 %!demo |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
188 %! clf; |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
189 %! x = [0 0 |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
190 %! 1 0.5 |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
191 %! 1 0.5 |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
192 %! 0 0]; |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
193 %! y = [0 0 |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
194 %! 0 0 |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
195 %! 1 0.5 |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
196 %! 1 0.5]; |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
197 %! c = [1 2 3 4]'; |
d7c88126ac03
fill.m: Don't replicate cdata matrix to x,y size when it is a string.
Rik <rik@octave.org>
parents:
18072
diff
changeset
|
198 %! fill (x, y, c); |
18405 | 199 %! title ({'fill() function'; 'cdata = column vector produces FaceColor = "interp"'}); |
200 |