Mercurial > hg > octave-nkf
changeset 13954:2ebbc6c9961b
[Bug #34559] Clean-up __patch__.m and add support for RGB cdata.
* plot/private/__patch__.m (__patch__): Predefine h output argument. Support
CDATA specified in RGB format.
(setdata): Removed unused variables.
(setvertexdata): Likewise. Support case where [x|y]data are specified as row
vectors.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Mon, 28 Nov 2011 22:19:45 +0000 |
parents | 642e43164af6 |
children | ffbbe6719ef5 |
files | scripts/plot/private/__patch__.m |
diffstat | 1 files changed, 25 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/private/__patch__.m +++ b/scripts/plot/private/__patch__.m @@ -29,6 +29,7 @@ function [h, failed] = __patch__ (p, varargin) + h = NaN; failed = false; is_numeric_arg = cellfun (@isnumeric, varargin); @@ -128,11 +129,29 @@ else error ("patch: color value not valid"); endif - elseif (size (c, ndims (c)) == 3) + elseif (isvector (c) && numel (c) == 3) args{7} = "facecolor"; args{8} = c; args{9} = "cdata"; args{10} = []; + elseif (ndims (c) == 3 && size (c, 3) == 3) + ## CDATA is specified as RGB data + if ((size (c, 1) == 1 && size (c, 2) == 1) ... + || (size (c, 1) == 1 && size (c, 2) == columns (x))) + ## Single patch color or per-face color + args{7} = "facecolor"; + args{8} = "flat"; + args{9} = "cdata"; + args{10} = c; + elseif (size (c, 1) == rows (x) && size (c, 2) == columns (x)) + ## Per-vertex color + args{7} = "facecolor"; + args{8} = "interp"; + args{9} = "cdata"; + agrs{10} = c; + else + error ("patch: color value not valid"); + endif else ## Color Vectors if (isempty (c)) @@ -231,11 +250,8 @@ fc = [0, 1, 0]; endif args = {"facecolor", fc, args{:}}; - else - fc = args {idx}; endif - nr = size (faces, 2); nc = size (faces, 1); idx = faces .'; t1 = isnan (idx); @@ -302,17 +318,19 @@ fc = [0, 1, 0]; endif args = {"facecolor", fc, args{:}}; - else - fc = args {idx}; endif [nr, nc] = size (x); + if (nr == 1 && nc > 1) + nr = nc; + nc = 1; + end if (!isempty (z)) vert = [x(:), y(:), z(:)]; else vert = [x(:), y(:)]; endif - faces = reshape (1:numel(x), rows (x), columns (x)); + faces = reshape (1:numel(x), nr, nc); faces = faces'; if (ndims (c) == 3)