Commit graph

834 commits

Author SHA1 Message Date
sapics
018cb6285a Add test for Path.Constructors initialization 2017-04-10 13:08:35 +09:00
Jürg Lehni
d436d07fee Intersections: Correctly handle item#applyMatrix = false
Closes #1289
2017-03-23 13:13:32 +01:00
Jürg Lehni
a43db8427a Boolean: update documentation and optimize #divide()
#divide() with options.trace = false can call splitBoolean() just once without removing any split sub-paths.

Relates to #1221
2017-03-22 23:45:11 +01:00
Jürg Lehni
15471c76ab Boolean: Always return CompoundPath items.
Relates to #1221
2017-03-22 23:26:26 +01:00
Jürg Lehni
3c9d2eea1d Boolean: Implement options.trace, and add unit tests for options.trace = false
Relates to #1221
2017-03-22 15:03:11 +01:00
Jürg Lehni
ffa7e16f48 Use == false instead of === false for all options that default to true.
These expression are true:
- false == false
- false == 0
While these are false:
- false == null
- false == undefined
2017-03-22 14:42:11 +01:00
Jürg Lehni
89d0536783 Scene Graphs: Do not allow inserting same item as child multiple times. 2017-03-21 11:55:42 +01:00
Jürg Lehni
49fca5510e Improve handling of Rectangle dimension properties.
Better deal with left / top / right / bottom / center values, and implement more unit tests for their behavior.

Closes #1147
2017-03-19 22:51:34 +01:00
Jürg Lehni
ab45002003 Tests: Clean up Rectangle unit tests. 2017-03-19 19:26:07 +01:00
Jürg Lehni
e354bccf69 Include note about compiling for Electron.
And some smaller forgotten changes.

Closes #1276
2017-03-19 14:38:24 +01:00
Jürg Lehni
fdd42076f9 Intersections: Bring back special handling of curve end-points.
Revert commit 89e31dd393, and add further improvements:

- Implement unit tests for #1284
- Remove Rectangle#touches(rect) in favor of #intersects(rect, epsilon)

Closes #1284
2017-03-18 16:42:55 +01:00
Jürg Lehni
993afe3c83 Tests: Implement unit tests for #1277 2017-03-12 11:11:14 +01:00
Jürg Lehni
5291043a5f Fix how gradient matrices are handled when Item#applyMatrix = false
Closes #1238
2017-03-09 14:31:41 +01:00
Jürg Lehni
083a09604d Hit-Tests: Fix issue with non-invertible matrices.
Closes #1271
2017-03-09 12:42:11 +01:00
Jürg Lehni
f9d06d8ae4 Hit Tests: Implement options.position.
Closes #1249
2017-03-08 23:01:12 +01:00
Jürg Lehni
db4deb244f Fix calculation of internal bounds with children and applyMatrix = false
Closes #1250
2017-03-08 17:14:42 +01:00
Jürg Lehni
65da4fe3ed Clear parent's bounds cache when item's visibility changes.
Closes #1248
2017-03-08 16:21:34 +01:00
Jürg Lehni
cbc873cfd8 Merge pull request #1265 from iconexperience/new-unite-tests
Add some unit tests for boolean unite operations
2017-03-08 15:47:54 +01:00
Jürg Lehni
5ea09c2fa2 Tests: Implement unit test for #1270.
Closes #1270.
2017-03-07 20:57:47 +01:00
Jürg Lehni
fd797425e0 Tests: Fix unit test for #1239.
Adjust for increase of found intersections since ecc1edb6ea.
2017-03-07 20:15:59 +01:00
Jürg Lehni
ecc1edb6ea Revert d204175d39
Revert fat-line clipping optimization that checked for straight curves, as unfortunately it wasn't reliable in many edge cases.

Relates to #1263
2017-03-07 20:01:05 +01:00
Jürg Lehni
867d0874dc Tests: Implement unit test for #1269.
Closes #1269.
2017-03-07 17:41:37 +01:00
Jürg Lehni
8461d8d9f4 Curve Intersection: Improve algorithm to work with correct version of isStraight()
Relates to #1269
2017-03-07 17:41:16 +01:00
Jürg Lehni
7448aedf67 Tests: Show SVG path data when boolean results are different. 2017-03-07 11:04:11 +01:00
iconexperience
5359bc428e Add some unit tests for boolean unite operations 2017-03-01 14:07:17 +01:00
Jürg Lehni
5c86330d6e Tests: Implement unit test for #1261. 2017-02-26 01:03:35 +01:00
Jürg Lehni
e3828d810b When aborting fat-line clipping, attempt an approximation with line intersections. 2017-02-22 13:58:27 +01:00
Jürg Lehni
d204175d39 Improve and optimize fat-line clipping algorithm.
By checking if subdivided curves are straight and falling back on line-line / line-curve approach if they are.
2017-02-21 23:09:30 +01:00
Jürg Lehni
f16b91e0fe Tests: Implement unit test for #1233 2017-02-21 22:10:08 +01:00
Jürg Lehni
357ff0dd43 Reduce epsilon in fat-line clipping to 1e-12 and adjust unit tests.
These results make much more sense and the algorithm finds less false positives while still behaving reliably in all edge cases.
2017-02-16 14:05:05 +01:00
Jürg Lehni
69c124c36c Merge remote-tracking branch 'origin/improved-reorient' into develop
; Conflicts:
;	src/path/PathItem.Boolean.js
2017-02-04 20:20:21 +01:00
Jürg Lehni
535607931c Unit tests for boolean operations without crossings.
Closes #1113
2017-02-04 20:15:23 +01:00
Jürg Lehni
6ad5bfafee Implement unit test for #1073
Closes #1073, closes #1074
2017-01-25 07:55:37 -05:00
Jürg Lehni
cf2ebbaaf8 Partly revert 09785a504b
To make the edge-case in #1239 work again. Also add unit tests for edge-case.
2017-01-15 11:34:02 +01:00
Jürg Lehni
e7b53c8a22 Implement Curve#classify() based on Loop and Blinn.
And use it to simplify curve self-intersection handling.

Relates to #773, #1074, Closes #1235
2017-01-11 15:01:10 +01:00
Jürg Lehni
2145efb29b Implement more unit tests for #1109
Closes #1109
2017-01-08 15:14:47 +01:00
Jürg Lehni
673d157f31 Implement unit tests for #1116
Closes #1116
2017-01-08 15:07:40 +01:00
Jürg Lehni
0ae2ded9cc Fix handling of hit-test tolerance on scaled items with #applyMatrix = false
Closes #1195
2017-01-08 14:34:58 +01:00
Jürg Lehni
46fce16bff Fix handling of overlapping paths for subtract and exclude operations.
Closes #1139
2017-01-03 00:50:22 +01:00
Jürg Lehni
c21e19b303 Fix overlap sequence handling in Path#compare()
Closes #1223
2016-12-31 06:49:57 +01:00
Jürg Lehni
7d3d7351ab Implement more PathItem#compare() tests.
Two failing for now.
2016-12-31 01:07:50 +01:00
Jürg Lehni
d405f45d38 Correctly handle offset in Curve#divideAt(offset)
Closes #1230
2016-12-31 00:34:37 +01:00
Jürg Lehni
771bb61038 Fix matrix cloning for groups with #applyMatrix = false
Closes #1225
2016-12-30 13:25:08 +01:00
Jürg Lehni
c12f7c4a64 Start implementing unit tests for PathItem#compare() 2016-12-29 10:56:06 +01:00
Jürg Lehni
97abd80bab Replace all occurences of Math.sqrt(2) with Math.SQRT2 2016-12-29 10:56:06 +01:00
Jürg Lehni
41f7e58ca9 Include issue number forgotten in previous commit. 2016-12-23 23:13:18 +01:00
Jürg Lehni
b59baeb9aa Fix stroke hit-testing for rounded shape items.
Closes #1207
2016-12-23 23:11:17 +01:00
Jürg Lehni
3c43a78c53 Properly handle generated IDs in SVG export.
Closes #1138
2016-11-20 20:53:41 -05:00
Jürg Lehni
8946f44ed9 Fix curve-bounds check in getIntersections()
Closes #1197
2016-11-20 20:19:38 -05:00
Jürg Lehni
6dd7cc5b6a Fix imprecision in Numerical.findRoot()
Results can be slightly outside of the range.
Close #1149
2016-09-24 15:39:09 -04:00
Jürg Lehni
80f6dbb5e3 Implement unit test for #1091
Closes #1091
2016-09-24 14:53:36 -04:00
Jürg Lehni
287f48a0db Implement unit test for #1165
Closes #1165
2016-09-24 14:34:46 -04:00
Jürg Lehni
b37b8cc495 Improve reliability of Curve.getIntersection()
Reduce epsilon when checking against curve end points from GEOMETRIC_EPSILON to EPSILON.

Coses #1174
2016-09-24 14:28:43 -04:00
Jürg Lehni
b4f6cde203 Tests: Handle null values when comparing items. 2016-09-20 18:43:02 -04:00
Jürg Lehni
3a49ac4015 Handle paths with only one segment in #resolveCrossings()
Closes #1167
2016-09-20 18:13:47 -04:00
Jürg Lehni
6e7fe67a8d Implement unit tests for #1109. 2016-08-09 10:01:35 +02:00
Jürg Lehni
7a63afc769 Clean up Layer unit tests a bit. 2016-08-07 15:58:54 +02:00
sapics
31690cb6b6 Fix to remove named layer 2016-08-06 11:00:29 +09:00
Jürg Lehni
bcd02129a3 Implement additional unit test for #1054. 2016-07-27 20:12:29 +02:00
Jürg Lehni
14b2d76450 Boolean: Improve handling of visited segments in intersect() operations.
Closes #1123
2016-07-27 19:35:19 +02:00
Jürg Lehni
e643338422 Add options object to boolean operations and improve handling of open paths.
This closes #1036, closes #1072, closes #1089 and closes #1121
2016-07-27 17:09:52 +02:00
Jürg Lehni
3f76bd99ef Implement an efficient mechanism to prioritize key in Item#set()
Closes #1096
2016-07-25 23:17:45 +02:00
Jürg Lehni
4954f5d6ab Improve Style#equals() to correctly handle default values.
Closes #1084
2016-07-25 21:42:06 +02:00
Jürg Lehni
29768c8228 Take Color#alpha default into account in Color#equals()
Relates to #1084
2016-07-25 21:09:53 +02:00
Jürg Lehni
eab0b9db5e Correctly handle path.replaceWith(path) calls.
Closes #1118
2016-07-22 23:29:33 +02:00
Jürg Lehni
cbe41c536e Boolean: Return the full winding object from _getWinding() and use it to improve PathItem#contains() with even-odd full-rule.
Also store the full winding object on the processed segments, to have more information available in boolean operations.
2016-07-22 15:46:42 +02:00
Jürg Lehni
23f3097f84 Facilitate code minification in PathIterator. 2016-07-22 14:21:35 +02:00
Jürg Lehni
becac4c921 Use shorter zero checks for array indices and length.
Keeping === 0 for mathematical algorithms seems clearer.
2016-07-22 13:46:24 +02:00
Jürg Lehni
3d57216ffe Update test for #944 to work with new way of handling compound-paths.
But keep deactivated as it is currently failing, see #1116
2016-07-22 13:15:05 +02:00
Jürg Lehni
a0417040f8 Improve handling of sub-path orientation in CompoundPath.
Remove automatic orientation on insertion, as it caused more troubles than solved problems, in favor of the new PathItem#reorient() method, or the even-odd fill-rule.

Closes #590, #1029
2016-07-21 15:21:45 +02:00
Jürg Lehni
16e53cc1ad Minor reformatting and changes.
no need for paper namespace in unit test code
2016-07-20 17:58:47 +02:00
Jürg Lehni
58991a569e Merge pull request #1115 from iconexperience/addCurveIntersections-patch
Improve fat line clipping to fix #1088
2016-07-20 17:56:04 +02:00
Jan
381e92501a Add test for #1088 2016-07-20 16:33:13 +02:00
Jürg Lehni
a683486ff5 Some code cleanup for previous commits, and shorten boolean tests a bit. 2016-07-20 16:32:21 +02:00
Jürg Lehni
f988445dad Boolean: Implement optimization for operands without crossings.
Closes #1113
2016-07-20 16:15:10 +02:00
Jan
46d0bf2d7d Add tests from W3C SVG Test Suite 2016-07-20 15:29:19 +02:00
Jürg Lehni
c338e9a6ec Tests: Add another SVG path data test. 2016-07-20 15:10:23 +02:00
Jürg Lehni
0b672cfb62 Merge branch 'new-winding' into develop 2016-07-19 14:27:45 +02:00
Jürg Lehni
e539633852 Implement new and shorter segments array notation.
Supporting:

- Closing paths by including `true` as the last entry
- Nested segment arrays that can be passed to PathItem.create() and the CompoundPath constructor to create all sub-paths
2016-07-19 13:08:21 +02:00
Jürg Lehni
13a68cec46 Fix failing unit test, and some code cleanup. 2016-07-19 10:24:37 +02:00
Jürg Lehni
288c3d4012 Fix issue in setPathData(), horizontal or vertical lineto and relative moveto commands.
Relates to #1101
2016-07-19 10:09:55 +02:00
Jürg Lehni
32d8c969fb Clean up handling of #_set(), #set() and #initialize()
Convention:

- #_set() is for actually setting properties, e.g. on Point, Size, so that derived classes can reuse other parts (e.g. SegmentPoint)
- #set() is a shortcut to #initialize() on all basic types, to offer the same amount of flexibility when setting values.
2016-07-18 20:11:01 +02:00
Jürg Lehni
2e054ecf47 Deactivate unit test for #944 edge case for now… 2016-07-18 16:13:33 +02:00
Jürg Lehni
e7c53b904c Implement unit test for #973. 2016-07-18 14:11:34 +02:00
Jürg Lehni
a1666a9b82 Implement additional unit tests for path#getInteriorPoint() 2016-07-17 23:10:47 +02:00
Jürg Lehni
ac97b9d9d7 Implement unit test for #1075 2016-07-17 21:16:52 +02:00
Jürg Lehni
38e5fc1488 Tests: Reference GitHub issues where they're knonw in PathItem#contains() tests. 2016-07-14 09:32:29 +02:00
Jürg Lehni
8a45c5dff9 Fix Node.js unit-tests, and add CHANGELOG entry for #1103 2016-07-12 19:27:35 +02:00
Jürg Lehni
89c60b1a05 Loosely couple Node.js code to canvas module.
Treat absence of canvas module like a web worker context.
Relates to #1103
2016-07-12 19:11:09 +02:00
Jürg Lehni
02658c9e74 Clean-up code from PR #1087
Closes #1085
2016-07-09 01:01:19 +02:00
Jürg Lehni
1914e64e4b Fix boolean tests to compare with improved results.
Disovered thanks to @sapics' improved solveCubic() in #1087
2016-07-08 23:05:50 +02:00
Jürg Lehni
45ffc6fb88 Improve Segment constructor to correctly handle undefined values.
Closes #1095
2016-07-03 13:30:56 +02:00
Jürg Lehni
0cb9c50e8f Implement unit test for #1054
Closes #1054
2016-06-13 14:54:13 +02:00
Jürg Lehni
ea5a635edf Implement unit tests for #964
Closes #964.
2016-06-13 14:51:38 +02:00
Jürg Lehni
742401a0e1 Fix Item#insertChildren() error when passing null for some children.
Relates to #1036
2016-06-13 14:16:25 +02:00
Jürg Lehni
4966f6250f Implement better calculation of tangential angles in CurveLocation#isCrossing()
Relates to #1074
2016-06-12 18:53:14 +02:00
Jürg Lehni
5854c25dd5 Implement Curve#getOffsetAtTime() 2016-06-12 18:32:05 +02:00
Jürg Lehni
b0d0e41ddc Allow negative offsets in all Curve#get*At() methods.
To search from the end of the curve instead of the beginning.
2016-06-12 18:21:37 +02:00
Jürg Lehni
614c781f29 Put the recursion cap back into fat-line clipping code.
But use a higher value, and have it work in conjunction with call-count cap.
Relates to #1074
2016-06-12 17:07:43 +02:00
Jürg Lehni
452bbfdaa4 Add unit tests and change-log entry for #904
Closes #904
2016-06-11 13:13:08 +02:00
Jürg Lehni
de8b626033 Add tolerance argument to Path#join(path, tolerance) 2016-06-11 12:41:23 +02:00
Jürg Lehni
715025725d Improve handling of SymbolItem bounds with #applyMatrix = false.
Closes #1070
2016-06-10 21:32:22 +02:00
Jürg Lehni
ed3e283802 Fix Item#importJSON() to preserve #parent on existing, already inserted items.
Closes #1041
2016-06-10 17:45:02 +02:00
Jürg Lehni
803dfb6bb1 Improve reliability of Curve#isStraight()
Closes #1066
2016-06-10 12:33:44 +02:00
Jürg Lehni
83a20b4c11 Implement unit test for #1059.
Closes #1059.
2016-06-10 12:04:08 +02:00
Jürg Lehni
e1961c2b91 Implement unit test and changelog entry for #1064
Closes #1064.
2016-06-10 10:29:38 +02:00
Jürg Lehni
f19d0c8134 Rename GradientStop#rampPoint to #offset 2016-05-31 12:35:44 +02:00
Jürg Lehni
9017bf1767 Unit test: Fix PaperScript left-over in SVG Export. 2016-05-27 11:37:59 +02:00
Jürg Lehni
9aa29e0afc Add support for construction from strings to Point and Size. 2016-05-27 11:37:19 +02:00
Jürg Lehni
948a8af9a8 Fix Item#strokeBounds with #strokeScaling and #applyMatrix
Closes #1014
2016-05-22 21:17:24 +02:00
Jürg Lehni
cb0810d18a QUnit: Fix tests on Node v6. 2016-05-22 15:59:05 +02:00
Jürg Lehni
eceb133686 Tests: Second attempt to find fitting tolerance for failing gradient SVG export. 2016-04-13 14:37:13 -07:00
Jürg Lehni
6f4738f8b2 Tests: Increate tolerance for gradient SVG export. 2016-04-13 14:08:52 -07:00
Jürg Lehni
d8d61ff160 Fix #1015: Improve handling of already inserted children in#insertChildren() 2016-04-13 13:36:26 -07:00
Jürg Lehni
83a2fa0749 Implement unit test for SVG export of gradients.
Closes #1027
2016-04-06 20:05:32 -07:00
Jürg Lehni
5a9f3dfb27 Improve handling of local paths and CORS on Node.js 2016-04-05 12:11:54 -07:00
Jürg Lehni
27f866df61 Implement test for #1021. 2016-03-27 13:45:55 -07:00
Jürg Lehni
bb19fade56 Travis CI: More SVG test adjustments. 2016-03-17 11:59:41 +01:00
Jürg Lehni
beabd6bea1 Travis CI: Adjust SVG test tolerances. 2016-03-17 11:44:24 +01:00
Jürg Lehni
d6ce4705b7 Travis CI: Use Arial in all SVG tests and reduce tolerance. 2016-03-17 11:35:06 +01:00
Jürg Lehni
17555b1879 Travis CI: See if using Arial solves the failing test. 2016-03-17 11:26:21 +01:00
Jürg Lehni
f7bb96e8b9 Fix #1000: Improve calculation of length of straight curves.
Support sub-ranges now too, through Curve.subdivide()
2016-03-17 11:24:20 +01:00
Jürg Lehni
d93aca6b5c Refactor GradientStop: Improve handling of optionally defined color and rampPoint.
Relates to https://github.com/paperjs/paper.js/issues/1001#issuecomment-197557990
2016-03-17 09:38:42 +01:00
Jürg Lehni
d52a6f3107 SVG Import: Add more tests.
One currently failing.
2016-03-15 19:13:16 +01:00
Jürg Lehni
84d2a2f908 SVG Import: Fix issues with viewBox. 2016-03-15 19:00:35 +01:00
Jürg Lehni
7a4794dacf Add more unit tests for SvgImport.
Some currently failing.
2016-03-15 18:52:38 +01:00
Jürg Lehni
da7d0d8f75 Implement Path#splitAt(offset)
Also make sure the deprecated Path#split(offset) works as it used to. Relates to #563
2016-03-14 18:59:09 +01:00
Jürg Lehni
69c34707e7 fix #994: Revert commit b5af47a7b1
Revert back to correct implementation of Path#getArea() and implement unit tests for it.
2016-02-26 12:58:50 +01:00
Jürg Lehni
1cb291690d Implement unit tests for #991
Tests for item.addChildren()/removeChildren(), some currently failing.
2016-02-23 11:55:03 +01:00
Jürg Lehni
50bd5bee6f SVG: Add comments explaining IE related changes in #984 2016-02-20 00:19:36 +01:00
Jürg Lehni
6df4602b2b Fix #977: Implement unit-tests. 2016-02-16 20:52:07 +01:00
Jürg Lehni
3d330da4fc Fix failing unit tests. 2016-02-15 09:21:11 +01:00
Jürg Lehni
08e51b5ca4 Fix failing SVG unit test. 2016-02-15 08:42:59 +01:00
Jürg Lehni
6f4890c63c Implement new options to control bounding box in SVG Export
And use it to support SvgExport unit tests. Relates to #972
2016-02-15 00:13:38 +01:00
Jürg Lehni
0e2498bdce Switch to PathItem.create() in unit tests. 2016-02-14 23:22:39 +01:00
Jürg Lehni
dba4eb371d SvgImport: Implement options.insert to control insertion.
Also use settings.insertItems for faster import. Closes #763
2016-02-14 22:51:50 +01:00
Jürg Lehni
8d5c922c50 Simplify code from #971 and activate unit test for it again. 2016-02-14 22:15:55 +01:00
Jürg Lehni
01fade8c08 Implement more unit tests for PaperScope#settings.insertItems 2016-02-14 22:04:40 +01:00
Jürg Lehni
4e7fa2f04e Implement PaperScope#settings.insertItems
Controlling whether newly created items are automatically inserted into the scene graph.
2016-02-14 21:34:35 +01:00
Jürg Lehni
56dd636f22 JSON: Improve serialization and deserialization on objects other than Item.
Closes #392
2016-02-14 17:16:40 +01:00
Jürg Lehni
2025bd1a77 SvgImport: Implement onError() callback
Closes #969
2016-02-14 14:52:37 +01:00
Jürg Lehni
fa6c1f47b4 Hit-Test: Pass viewMatrix as argument instead of in options object. 2016-02-14 13:34:35 +01:00
Jürg Lehni
9c9f43d2c9 Implement failing test for #968 2016-02-14 12:44:03 +01:00
Jürg Lehni
4a947317fb Implement #hitTestAll() on Item and Project
Along with unit tests and documentation.
Closes #536
2016-02-14 12:39:35 +01:00
Jürg Lehni
3ee46ffc5c Matrix: Switch to a better implementation of #decompose()
This now also correctly handles skewing in SVG export.
2016-02-14 10:59:57 +01:00
Jürg Lehni
c3fff9fa83 Switch from new Base() to Base.set({}) where possible. 2016-02-13 23:10:09 +01:00
Jürg Lehni
009761d13c Boolean: Only compare segments when determining if paths are identitcal. 2016-02-13 22:58:42 +01:00
Jürg Lehni
3348fb736f Boolean: Implement proper handling of fully overlapping (identical) paths and sub-paths.
Closes #923, closes #958
2016-02-13 22:41:09 +01:00
Jürg Lehni
84a75e375a Remove unnecessary edge-case handling in CurveLocation#isCrossing()
Closes #951, closes #959
2016-02-12 20:52:19 +01:00
Jürg Lehni
e2bc83af5d Add test for #960 and improve fix a bit.
Closes #960
2016-02-12 20:19:40 +01:00