SVG::Estimate - Estimates the length of all the vectors in an SVG file.
my $se = SVG::Estimate->new(
file_path => '/path/to/file.svg',
$se->estimate; # performs all the calculations
my $length = $se->length;
SVG::Estimate is a suite of modules that allow you to accurately estimate the length of the vectors inside of a Scalable Vector Graphics (SVG) file. It is only an estimate because we lack the math to give absolutely precise lengths of really complex curves in a time-efficient manner. Therefore, we take guesses in some cases, though those guesses are still quite accurate (to within about 0.1%). In a battery of tests against our own equipment, our measurements were more accurate than those provided by the equipment itself.
This is highly useful for any 2 dimensional CNC machines that use vector files to create tool paths, as you may want to know how long a job will take to quote your customer.
This class consumes SVG::Estimate::Role::Round.
A hash of properties for this class.
The path to the SVG file.
Have each parse SVG object emit its starting coordinates, ending coordinates, travel length, shape length and total length, all in pixels.
Returns the length in user units (pixels) of the SVG. This is equivalent of adding travel_length and shape_length together. NOTE: The number of user units within any given element could be variable depending upon how the vector was specified and how the SVG editor exports its documents. For example, if you have a line that is 1 inch long in Adobe Illustrator it will export that as 72 user units, and a 1 inch line in Inkscape will export that as 90 user units.
Returns the length of tool travel in user units that a toolhead would have to move to get into position for the next shape.
Returns the length of the vectors (in user units) that make up the shapes in this document.
The count of all the shapes in this document.
Returns a point (an array ref with 2 values) of where the toolhead will be at the end of estimation.
Returns the left most x value of the bounding box for this document.
Returns the right most x value of the bounding box for this document.
Returns the top most y value of the bounding box for this document.
Returns the bottom most y value of the bounding box for this document.
Reads in the SVG document specified by file_path in the constructor.
Performs all the calculations on this document. NOTE: before estimate() is run, none of the measurements will produce valid values.
This is used by estimate to do calculations on the various elements of the document. It recurses over a list of elements. This method is likely only useful to you if you want to evaluate only a section of a document.
An array reference of SVG elements as parsed by XML::Hash::LX.
Removes the - added to attributes by XML::Hash::LX and returns a hash with the fixed paramter names.
A hash reference of parameters from XML::Hash::LX with the preceeding - on each key.
Moo Math::Trig Image::SVG::Path Image::SVG::Transform Clone List::Util List::MoreUtils Ouch Test::More File::Slurp XML::LibXML XML::Hash::LX
This module was created by JT Smith <jt_at_plainblack_dot_com> and Colin Kuskie <colink_at_plainblack_dot_com>.
SVG::Estimate is Copyright 2016 Plain Black Corporation (http://www.plainblack.com) and is licensed under the same terms as Perl itself.
To install SVG::Estimate, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.