/usr/share/freemat/toolbox/graph/patch.m is in freemat-data 4.0-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | % PATCH PATCH Patch Graphics Function
%
% Usage
%
% This routine is used to create a patch object that can be plotting 2D and 3D surfaces. A
% patch is a polygon defined by the xyz coordinates
% of its vertices and optionally by the color at the vertices.
% There are several forms for the patch function:
%
% h = patch(X,Y,C,properties...)
% h = patch(X,Y,Z,C,properties...)
% h = patch(properties...)
% h = patch(V)
%
% Where X, Y and Z are matrices or vectors of x, y or z coordinates
% and C is a matrix or vector of color values (the colormap
% for the current fig is applied).
% Copyright (c) 2002-2008 Samit Basu, Eugene Ingerman
% Licensed under the GPL
function ohandle = patch(varargin)
if( nargin==1 )
error('not implemented')
end
% search for the propertyname/value pairs
propstart = 0;
if (nargin > 2)
propstart = nargin-1;
while ((propstart >= 1) && isa(varargin{propstart},'char') && ...
pvalid('patch',varargin{propstart}))
propstart = propstart - 2;
end
propstart = propstart + 2;
end
propset = {};
if ((propstart > 0) && (propstart < nargin))
propset = varargin(propstart:end);
varargin(propstart:end) = [];
end
if (length(varargin) == 0)
h = hpatch(propset{:});
elseif (length(varargin) == 3)
[vertices, faces, facevertexcdata]=parse_input( varargin{1}, varargin{2}, ones(size(varargin{1})), varargin{3} );
h = hpatch('xdata',varargin{1},'ydata',varargin{2},'zdata',ones(size(varargin{1})),'cdata',varargin{3},...
'faces',faces,'vertices',vertices,'facevertexcdata',facevertexcdata,'facecolor','flat','edgecolor','flat',propset{:});
elseif (length(varargin) == 4)
[vertices, faces, facevertexcdata]=parse_input( varargin{1}, varargin{2}, varargin{3}, varargin{4} );
h = hpatch('xdata',varargin{1},'ydata',varargin{2},'zdata',varargin{3},'cdata',varargin{4},...
'faces',faces,'vertices',vertices,'facevertexcdata',facevertexcdata,'facecolor','flat','edgecolor','flat',propset{:});
else
error('Unrecognized arguments to patch command');
end
if (nargout > 0)
ohandle = h;
end
function [vertices, faces, facevertexcdata]=parse_input( xdata, ydata, zdata, cdata )
if( size(xdata) ~= size(ydata) | size(xdata) ~= size(zdata) | length(size(xdata))>2 )
error('Data size mismatch');
end
[nx ny]=size(xdata);
sz = size(cdata);
if( ~( (sz(1)==1) | (sz(1)==1 & sz(2)==nx) | (sz(1)==ny & sz(2)==nx) ) )
error('CData size mismatch');
end
vertices=[xdata(:) ydata(:) zdata(:)];
faces = reshape( 1:nx*ny, size(xdata) )';
facevertexcdata = cdata; %cdata(:);
|