Commit Graph

145 Commits (8df19f1c12ec5de9ec74a628bf69b9cfc0522784)

Author SHA1 Message Date
Andy Port ab44fcd564 save and write fixed, __repr__() and pretty() methods added 2020-06-23 22:42:23 -07:00
Andy Port 4b7f17c7bd minor line width fix 2020-06-23 22:18:26 -07:00
Andy Port 70534a6b6c added vectorized points() method for bezier segments 2020-06-23 22:16:09 -07:00
Andy Port 1f7503aabd some renames and add __repr__ and pretty() 2020-06-23 21:54:58 -07:00
Andy Port 445899b2eb renamed Document.flatten_all_paths to flattened_paths 2020-06-23 20:54:27 -07:00
Andy Port d673176347 Document now stores element and transform in path and Document.display() is fixed 2020-06-23 20:50:43 -07:00
NataliaTs b503b9b3a5
fix polyline and polygon conversion (#85)
* fix polyline and polygon conversion

* update version

* revert version
2020-06-19 20:32:01 -07:00
Andy Port b714ff872d add Path.attributes and Path.meta attributes 2020-06-19 20:21:28 -07:00
Sebastian Kuzminsky 685f9a6eaf
fix Arc/Arc intersections (#110)
* add some failing Arc.intersect(Arc) tests

* implementing Arc.intersect(Arc)

This commit adds special handling in Arc.intersect() when the other
segment is an Arc, and when both segments are circular and non-rotated.

This particular case is common, and quick and easy to solve algebraically.

This commit fixes the failing tests added in the previous commit.
2020-06-19 19:40:38 -07:00
Matthew Carruth 5ae88df6d5
actually return svgwrite.Drawing if requested (#102)
no use having the option if the wsvg and paths2Drawing entry points do not return `dwg` back from disvg
2020-06-19 19:39:38 -07:00
David Romero 90f8f76185
Method for checking if one path is inside another path (#105)
* Added method is_contained_by to the Path class

* Adding a requirements.txt file

Signed-off-by: David Romero <dromero.fisica@gmail.com>

* Correcting tests of is_contained_by
2020-06-19 19:36:22 -07:00
Grey f99f9d6bb3
Support flattening paths of only nested groups (#88)
* Fixed document.flatten_group(~) for nested groups and added a test

* Add space for PEP8 conformance

* Add documentation for document.get_group()

* Use group_search_xpath to be consistent and customizable

* Fix lexical mistake in comments

* Fix grammar mistake in comments
2020-06-19 18:59:47 -07:00
Antoine Beyeler b117f85811
Fixed crash in line2pathd() (#101)
* Fixed crash in line2pathd().

* Further fixed to support implicit attributes
2020-06-19 18:58:25 -07:00
Antoine Beyeler b767536e38
Fixed MutableSequence import (importing from collections is deprecated) (#100) 2020-06-19 18:52:09 -07:00
Sebastian Kuzminsky 929202aa62
Cache arc length (#82)
* add Arc.__hash__()

This function returns a hash of the Arc parameters, providing a kind of
Arc object fingerprint.

* Arc: cache segment length

Computing the length of an Arc segment takes a relatively long time.

This commit teaches the Arc class to remember its segment length,
to avoid recomputing it.  It invalidates the cache and recomputes the
segment length if any of the Arc parameters have changed.
2020-06-19 18:45:56 -07:00
taoari c7b6c030a6
relative path support (#81)
* relative path support

* add test for path.d(rel=True)

* add path test to test_path.py
2020-06-19 18:43:29 -07:00
Sebastian Kuzminsky 8457dc01ee
fix Arc.sweep when transform scale flips it around (#112)
Fixes #111.
2020-06-19 18:29:36 -07:00
skef fd7348a1df Fix tuple assignment (#86) 2019-01-07 21:24:35 -08:00
Andy ae42197d10 fixed path area (issue #74) 2018-12-03 22:27:59 -08:00
Sumeet P b4e211fd79 cx and cy to be 0 for circle/ellipse by default (#78)
When cx and cy attributes are not defined either in ellipse or circle tag, consider both to be 0.
2018-11-13 15:43:09 -08:00
Andy Port 58d48029ac fixed bug in new Arc-friendly Path.area() method 2018-11-04 22:22:20 -08:00
Sebastian Kuzminsky b37e74f5f3 Update Path.area to work with Arc segments (#65)
* add some tests of Path.area()

These tests currently fail because area() doesn't deal with Arc segments.
Fix in the following commit.

* make Path.area() approximate arcs

Fixes #37.

* Path.area(): fixup tabs/spaces for python3

* added asin to imports

* added asin to imports

* minor improvements to style, performance, and docstring
2018-11-04 21:40:56 -08:00
tatarize e91a35c3da Basic Svg_Io_Sax (#66)
* Basic Svg_Io_Sax

* Update to binary write

* Fixed SaxSvg Load, tweaked test.

* Couple tweaks.

* Couple tweaks to fit the dom parser api better

* Switch to iterparse for speed

* Used None matrix for identity in default case.

* Test Update for None Matrix
2018-11-04 21:07:40 -08:00
Sebastian Kuzminsky 2feb3c92b5 Arc line intersect, 3rd try (#64)
* add Line.point_to_t() and tests

These tests don't print anything while they run, and they use use the
assert() helpers from the unittest module.

* add Arc.point_to_t() and tests

These tests don't print anything while they run, and they use use the
assert() helpers from the unittest module.

* add a bunch of failing arc/line intersection tests

This commit contains a bunch of failing arc/line intersections that I
and other people have run into.

These tests don't print anything while they run, and they use use the
assert() helpers from the unittest module where possible.

All these tests are fixed in the following commit.

* better implementation of Arc.intersect(Line)

Fixes mathandy/svgpathtools#35.

This commit fixes all the arc/line intersection test cases added in the
previous commit.

This implementation provides special handling in Arc.intersect() when
`self` is a non-rotated Arc and `other_seg` is a Line.  In this case
it uses the straight-forward closed-form solution to identify the
intersection points.

Rotated Arcs and Arcs intersecting with non-Line objects still use
the pre-existing intersection code, that part is totally untouched by
this commit.
2018-11-04 20:55:17 -08:00
Andy Port 74a881a181
Added paths2Drawing 2018-10-18 21:28:34 -07:00
Andy Port a86be9d306
added paths2Drawing functionality 2018-10-18 21:27:04 -07:00
Andy Port ee8eda5aae now `dimensions` parameter supports units will specify `viewbox` if not given 2018-10-13 22:22:52 -07:00
Andy Port aa03a4aecb now parameter supports units will specify if not given 2018-10-13 21:40:35 -07:00
Andy Port 95179a6bfa fixed issue with parameter being ignored 2018-10-13 20:36:01 -07:00
Andy Port 7fa103e533 Fixed issue with viewbox being written as tuple 2018-10-13 19:50:33 -07:00
Andy Port 165372562e
Revert "Arc line intersect, take 2 (#60)" (#63)
This reverts commit 2da39e4c02.
2018-08-22 00:27:55 -07:00
Sebastian Kuzminsky 2da39e4c02 Arc line intersect, take 2 (#60)
* add Line.point_to_t() and tests

* add Arc.point_to_t() and tests

* add a bunch of failing arc/line intersection tests

This commit contains a bunch of failing arc/line intersections that I
and other people have run into.

All these tests are fixed in the following commit.

* better implementation of Arc.intersect(Line)

Fixes mathandy/svgpathtools#35.

This commit fixes all the arc/line intersection test cases added in the
previous commit.

This implementation provides special handling in Arc.intersect() when
`self` is a non-rotated Arc and `other_seg` is a Line.  In this case
it uses the straight-forward closed-form solution to identify the
intersection points.

Rotated Arcs and Arcs intersecting with non-Line objects still use
the pre-existing intersection code, that part is totally untouched by
this commit.
2018-08-22 00:19:05 -07:00
Andy Port 4bc146fd62 save() now requires filename 2018-08-21 21:27:29 -07:00
Andy Port 0955278f73 aesthetic cleanup 2018-08-21 21:10:27 -07:00
Andy Port 7ebc56a831 aesthetic cleanup 2018-08-21 20:54:02 -07:00
Andy Port 40a515ee63 removed all np.matrix uses (deprecation) 2018-08-21 20:05:59 -07:00
Andy Port 3d1a225503 removed future dependencies 2018-08-21 19:39:25 -07:00
Michael X. Grey 360d6b224c Flattening SVG groups and handling transforms (#55)
* Some progress (and added CONTRIBUTING.md)

* fixed documentation line-width to be PEP 8 compliant

* fixed documentation line-width to be PEP 8 compliant

* style changes

* made some design changes

* Make the Document class available when importing the library

* Add a method to parse transform strings

* Iterate on the implementation of the Document class

* Tweaks to transform parsing implementation

* Implementing a depth-first flattening of groups

* Finish implementation of flatten_paths

* Beginning to write tests for groups

* Refactoring flatten_paths() into flatten_all_paths()

* Clean up implementation of document classes

* Debugging xml namespace behavior -- needs improvement

* Improve the way the svg namespace is handled

* Print out some paths to see that they're sane

* Fix multiplication of numpy matrices -- need to use .dot() instead of operator*

* Create a unit test for parsing SVG groups

* Return a reference to an element instead of a copied dictionary of attributes

* Add a test for <path> elements that contain a 'transform' attribute

* minor docstring improvements

* got rid of svg2path changes (reverted to master)

* updated to match master

* Remove accidental paranthesis

* Remove unnecessary import

* Use a default width and height of 0, as dictated by SVG specs, in case width or height is missing

* Expose the CONVERSIONS and CONVERT_ONLY_PATHS constants

* Fix the use of some numpy operations

* Remove untested functions

* Fix add_group() and write tests for adding groups and paths

* Update documentation of document module

* Add tests for parsing transforms

* Update the module name for svg_to_paths

* Improve Python3 compatibility

* Try to improve compatibility

* More tweaks for compatibility
2018-08-21 18:00:29 -07:00
Andy ccc9ee6ae1 added clipping to work around floating point error in Arc._parameterize() 2018-07-24 15:07:02 -07:00
Andy b47345da91 added clipping to work around floating point error in Arc._parameterize() 2018-07-24 14:57:54 -07:00
Andy fd521748fa fixed scaled (before cleanup) 2018-07-06 22:59:28 -04:00
Andy 31a8d2ac11 rgb2hex now allows lists as input 2018-06-10 14:41:27 -07:00
Andy 850055fa57 fixed bez2poly function 2018-06-10 14:38:08 -07:00
Andy a2ea4a0e80 fixed path curvature 2018-06-10 14:33:17 -07:00
Andy fd95b5609f partially fixed scale fcn and improved tests 2018-06-08 22:13:18 -07:00
mdejean f932036fb5 After Z, next subpath starts at same position (#53)
* After Z, next subpath starts at same position

Fixes #52

* removed old comment to mirror new behavior
2018-06-02 00:49:49 -07:00
Andy Port 18b1337877 renamed svg2paths module to allow imports 2018-06-02 00:32:16 -07:00
Andy Port 55661d18a4
Merge pull request #54 from playi/scale
add scale() for curves, and scaled() for paths
2018-05-30 21:20:22 -07:00
Andy Port 72d7467896
implemented (almost) full SVG scale transform functionality 2018-05-30 19:07:58 -07:00
Orion Elenzil ee656c7de0 refactor `scale()` and `scaled()` to `scale_uniform()` and `scaled_uniform()` 2018-05-30 10:54:56 -07:00
Andy Port 6fcc71d63b minor docstring improvements 2018-05-28 19:46:38 -07:00
Dmitry_Milk 2dcfa88cf2 Adjust polyline/polygon parsing to W3C specification
https://www.w3.org/TR/SVG11/shapes.html#PointsBNF
2018-05-27 11:47:44 +03:00
Andy Port 0827206953
style changes 2018-05-22 19:59:03 -07:00
Orion Elenzil d21a66aff0 add scale() for curves, and scaled() for paths 2018-05-22 12:45:04 -07:00
Andy Port 71b4403375
fix typo `joins_smoothl_with` 2018-04-13 14:34:28 -07:00
Andy Port a50c522f86
use np.close to check to check for vanishing denom
Just to offer users some amount of control over the tolerance.
2018-02-27 22:38:01 -08:00
Sebastian Kuzminsky 89d9acf06e Line.intersect(Line): fix a "miss some intersections" bug
Negative numbers are allowed in the denominator, what we really want to
avoid is near-zero denominators.
2018-01-20 20:46:54 -07:00
Sebastian Kuzminsky fc34d2c4cf deal with float rounding error in Line.intersect(Line)
This commit fixes #41.

In the test case added in the previous commit, two non-intersecting lines
are very nearly collinear, but float rounding errors lead to incorrect
intersections reported.

This commit makes Line.intersect() treat denominators below 1e-9 as 0,
to make it more accepting of float rounding.
2018-01-06 23:15:43 -07:00
Anders Granskogen Bjørnstad ec63d0c312 Arc: Handle round-off issue with acos()
math.acos raises outside of valid range [-1, 1]. Handle round-off errors
gracefully by using `round()` here too.
2017-11-10 13:44:24 +01:00
Andy 586bccd0f2 now svgwrite debug is false by default 2017-07-18 20:01:37 -07:00
Andy 38eeac858c fixed support for rectangles when no x,y attributes are specified
defaults to 0,0
2017-04-26 02:21:01 -07:00
Andy d670547149 added polygon() and polyline() to __init__ 2017-04-26 02:20:11 -07:00
Andy a094f92b3a added polyline and polygon functions (points --> Path of Line objects) 2017-04-26 01:54:44 -07:00
Andy a3a529899c added rect element support to svg2paths 2017-04-26 01:53:34 -07:00
Andy 1d1bec1877 add ellipse/circle option to svg2paths2 and change return_svg_attributes to be second argument. 2017-04-23 01:14:59 -07:00
Andy aa02116e87 prettify svg2paths docstring (Google style) 2017-04-23 01:12:12 -07:00
Andy 900d5ba93b fixed typo and long line in docstrings 2017-04-23 00:45:41 -07:00
Andy Port 9a1b1ff1e5 Merge pull request #21 from jpcofr/ellipse_d_squashed
Added functionality to extract circle and ellipse elements from SVG files.  Circles and ellipses are treated as paths of two `Arc` objects.
2017-04-23 00:33:06 -07:00
Juan Pablo Contreras Franco 216965e6ab Corrected wrongly deleted docstring line 2017-04-23 07:50:43 +02:00
Juan Pablo Contreras 2a24cf640d Added functionality to process both circles and ellipses.
Added tests related to the functionality.
2017-04-07 09:44:04 +02:00
Andy Port d8dfbd01fc changed default (when svg_attributes doesn't have a height/width) to the szx and szy constructed from path bounding boxes
@DerVedro was there a reason you thought the default should be 100% (beyond that being the current behavior -- which I see as a bug)?
2017-04-06 16:05:28 -07:00
derVedro 88185419f5 fliped width and height
the x and y were swaped by my mistake
2017-03-31 00:26:02 +02:00
derVedro f72987d69b fixed ignored height and width arguments
issue #17 fix
2017-03-31 00:17:59 +02:00
Andy 385dbb7196 cleanup
removed commented-out “pathless_svg” functionality
2017-03-30 01:57:23 -07:00
Andy 60d67923b6 fix issue#15 Path.cropped() bug, and more
-also fixed <path>.cropped(1, 0) bug (now raises AssertionError)
-also now Path.cropped() raises AssertionError if given negative values
2017-03-30 01:38:27 -07:00
Andy 4ec69a4cff remove empty `pathtools.py` and move tests from `test_pathtools.py` to `test_path.py` 2017-03-24 00:18:22 -07:00
Andy 9423f5fdc3 fixed svg2path parsing of svg-polygon elements with redundant closure points 2017-03-16 01:58:48 -07:00
Andy 1655b77d15 removed builtins imports 2017-02-28 23:34:29 -08:00
Andy 8815ddcd52 futurized for Python 3 compatibility
and some other minor changes of no effect
2017-02-28 23:04:37 -08:00
Andy f697a91190 fixed higher order Bezier to polynomial conversion 2017-02-28 20:41:35 -08:00
Canule 70b03ad233 xrange 2017-02-26 23:42:13 +01:00
Andy d38485d69c minor bezier_intersections() docstring fix 2017-02-20 22:33:35 -08:00
Andy a154796576 changes related to arcs and intersections
-fixed quadratic/Arc intersections
-changed assertion that an arc's radii are positive to non-zero
-improved Arc.intersect() docstring to further explain partial
implementation
2017-02-20 22:10:16 -08:00
Andy a81af16d89 improved Arc docstring and added positive radii assertion to Arc 2017-02-20 20:11:54 -08:00
Andy c219d1e671 improved Arc class docstring 2017-02-20 19:46:16 -08:00
Andy 058b23585f fixed bug (issue #9) where line.intersect(curve) results are reversed 2017-02-20 19:21:07 -08:00
Andy 1622d01d05 add note that `svg_attributes={'debug': False}` increases `disvg`/`wsvg` speed considerably. 2017-02-05 23:18:23 -08:00
Andy 08e8dc71ff improve distribution to PyPI
Now svg files, readme, unit tests, and license included in PyPI dis
2016-10-29 00:35:51 -07:00
remi-pr 3575fec9af Fixed the rotated method of all objects
The rotated method of all objects was not using the origin argument but always self.point(0.5) even though it is all correctly handled in the rotate function they are all calling
2016-10-28 15:11:31 +02:00
Andy 6be04c6750 Fix python 3 incompatibility with Path.intersect() method 2016-10-16 00:20:52 -07:00
derVedro f782b628ff check for necessity of line on closing command 2016-10-09 07:45:42 +02:00
Andy a6719c56c5 fixed __init__.py 2016-07-23 17:15:22 -07:00
Andy 849ad17088 add polyroots01 to __init__.py 2016-07-22 18:44:34 -07:00
Andy 15d186ff33 add ability to preserve svg-attributes
Added svg_attributes attribute to wsvg and disvg.
Added return_svg_attributes option to svg2paths.
Added convenience function svg2paths2().
2016-07-15 22:10:59 -07:00
Andy 9b3d6fe5e3 initial commit 2016-07-05 21:51:11 -07:00