/usr/share/octave/packages/geometry-1.7.0/io/@svg/path2polygon.m is in octave-geometry 1.7.0-1build1.
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 | ## Copyright (C) 2012 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} @var{P} = path2polygon (@var{id})
## Converts the SVG path to an array of polygons.
##
## @end deftypefn
function P = path2polygon (obj,varargin)
narg = numel(varargin);
if narg == 1
id = varargin{1};
n = 32;
elseif narg == 2
id = varargin{1};
n = varargin{2};
else
error("svg:path2polygon:InvalidArgument", "Wrong number of arguments.");
end
P = shape2polygon(getpath(obj, id));
endfunction
#{
pd = obj.Path.(id).data;
P = cellfun(@(x)convertpath(x,n),pd,'UniformOutput',false);
P = cell2mat(P);
end
function p = convertpath(x,np)
n = size(x,2);
switch n
case 2
p = zeros(2,2);
# Straight segment
p(:,1) = polyval (x(1,:), [0; 1]);
p(:,2) = polyval (x(2,:), [0; 1]);
case 4
p = zeros(np,2);
# Cubic bezier
t = linspace (0, 1, np).';
p(:,1) = polyval (x(1,:),t);
p(:,2) = polyval (x(2,:),t);
end
end
#}
|