Commit graph

5504 commits

Author SHA1 Message Date
Jürg Lehni
677c073c84 Use GEOMETRIC_EPSILON instead of EPSILON in Path#arcTo() 2017-03-08 14:13:19 +01:00
Jürg Lehni
7a3e903b4d Add Line#getSignedDistance() 2017-03-08 14:12:49 +01:00
Jürg Lehni
155d5b879c Improve Path._addSquareCap() for use in path offsetting code. 2017-03-08 13:41:23 +01:00
Jürg Lehni
b587e0b5b8 Release version 0.10.3 2017-03-08 10:44:43 +01:00
Jürg Lehni
22bda0972d Intersections: Remove now unnecessary code.
Thanks to Curve#classify(), self-intersections are always in sequence.
2017-03-07 20:13:32 +01:00
Jürg Lehni
89e31dd393 Intersections: No more need for the special handling of curve end-points. 2017-03-07 20:11:04 +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
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
bad4d02766 Fix Curve#isStraight() to correctly consider handles.
Also include code that prevents Curve.getIntersections() from failing now. Work in progress. Relates to #1269
2017-03-07 14:13:39 +01:00
Jürg Lehni
1fad295600 Facilitate minification. 2017-03-07 12:34:59 +01:00
Jürg Lehni
d6c1ce2458 Make sure calls are always counted in addCurveIntersections()
recursions only need to be increased if we're not aborting.

See https://github.com/paperjs/paper.js/issues/1239#issuecomment-284265520
2017-03-06 11:32:18 +01:00
Jürg Lehni
b680ec05b9 Fix calls counting in addCurveIntersections() when dealing with straight curves.
See https://github.com/paperjs/paper.js/issues/1239#issuecomment-284340550
2017-03-06 10:13:14 +01:00
Jürg Lehni
b85fc988de Minor comment cleanup. 2017-03-01 12:37:08 +01:00
iconexperience
9f5f3192b7 Set curve time to 1 for curves completely right or left of point for better performance. Note that we cannot set the time to 0, because this would invoke special handling for crossing at the curve's start point. 2017-03-01 09:39:44 +01:00
iconexperience
86d05624c0 Fix addWinding() for special cases 2017-03-01 09:04:46 +01:00
Jürg Lehni
32db1eb005 Boolean: Some code and comment cleanup. 2017-02-26 01:11:33 +01:00
Jürg Lehni
4d3ca746ab Reduce windingEpsilon to 1e-9.
this address the issue outlined in https://github.com/paperjs/paper.js/issues/1261#issuecomment-282520748
2017-02-26 00:45:22 +01:00
Jürg Lehni
7b73ec238d Remove onPath winding hack again.
See #1073
2017-02-26 00:22:49 +01:00
Jürg Lehni
86478b6873 Boolean: Improve handling of branching at crossings. 2017-02-25 18:55:11 +01:00
Jürg Lehni
919c42af27 Implement Segment#isSmooth() and use it in handling of stroke-joins. 2017-02-25 15:45:58 +01:00
Jürg Lehni
f19a50093b Simplify handling of strokeJoin / strokeCap geometries. 2017-02-22 22:22:23 +01:00
Jürg Lehni
b40efbf6db Fix Line#getSide() imprecisions when points are on the line. 2017-02-22 17:41:51 +01:00
Jürg Lehni
6a4347e75b Optimize Curve#hasLength()
Only check the handles that are actually part of the curve.

Closes #1260
2017-02-22 17:29:23 +01:00
Jürg Lehni
919615f168 Remove CurveLocation#getOffsetTo() again. 2017-02-22 17:05:23 +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
ba2b18c7dc Small improvement in Path#arcTo() to reduce segment account in edge cases. 2017-02-22 13:57:51 +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
caac1c18e3 Implement CurveLocation#getOffsetTo(location) 2017-02-21 22:19:38 +01:00
Jürg Lehni
ee48e6cd03 Implement caching for CurveLocation#curveOffset. 2017-02-21 22:19:17 +01:00
Jürg Lehni
f089c3c620 Improve handling of new segments in CurveLocation#divide() and #split() 2017-02-21 22:16:55 +01:00
Jürg Lehni
ed57b82b19 Boolean: Improve handling of multiple crossings on the same curve. 2017-02-21 22:05:38 +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
2343ed5ca9 Remove checks for begin- and end-points in getCurveIntersections()
See #1239
2017-02-16 14:00:18 +01:00
Jürg Lehni
4f9d23da81 Use consistent boundary policy when dealing with curve-time. 2017-02-16 13:41:53 +01:00
Jürg Lehni
e3c6245979 Docs: Improve description of option.class value in #hitTest()
See #632
2017-02-15 16:11:33 +01:00
Jürg Lehni
1ff4bc9665 More cleanup in curve intersection code. 2017-02-12 15:52:56 +01:00
Jürg Lehni
2ead16ca89 Rename Curve.getCurvesIntersections() to Curve. getIntersections() 2017-02-12 15:47:01 +01:00
Jürg Lehni
bd98e067c3 Docs: Some cleanup in Curve. 2017-02-12 15:42:12 +01:00
Jürg Lehni
df7323da32 Improve handling of excludeStart / excludeEnd in curve intersections. 2017-02-12 15:27:59 +01:00
Jürg Lehni
45f5bf84e8 Enforce creation of Curve#values getter despite hidden parameter. 2017-02-12 12:15:59 +01:00
Jürg Lehni
286765f4b0 Further optimizations in getOverlaps() 2017-02-11 21:32:11 +01:00
Jürg Lehni
23202d0c80 Some code optimizations and cleanup. 2017-02-11 21:25:42 +01:00
Jürg Lehni
1b50355585 Improve getCurveIntersections() for use with neighboring curves.
As needed by bezier offsetting code.
2017-02-11 21:19:47 +01:00
iconexperience
af7b22a708 Add Line.getDistance() and use it in Curve.getOverlaps() 2017-02-07 16:15:41 +01:00
Jürg Lehni
13f4773985 Fix documentation of Project#hitTestAll()
Relates to #536
2017-02-06 18:36:00 +01:00
Jürg Lehni
b23c272d69 Minor code cleanup. 2017-02-06 16:46:22 +01:00
Jürg Lehni
4588a90952 Expose Curve.getCurvesIntersections()
To be used in offsetting code to check for self-intersections.
2017-02-06 16:37:05 +01:00
Jürg Lehni
fafbd9ad36 Expose Curve. getCurveLineIntersections() for curve offsetting. 2017-02-05 21:59:56 +01:00
Jürg Lehni
8c3c771891 Streamline handling of abscissa and ordinate flipping. 2017-02-05 21:59:29 +01:00
Jürg Lehni
1f768c69d2 Move private getPeaks() to Curve.getPeaks()
It will be of use in the offsetting code as well.
2017-02-05 14:20:43 +01:00
Jürg Lehni
7fc029d98b More quality related tweaks in getWinding() 2017-02-04 21:55:44 +01:00
Jürg Lehni
fb4a0b1fe0 No need to change the winding values here.
But onPath is crucial. Relates to #1073
2017-02-04 21:38:56 +01:00
Jürg Lehni
4d6ebe2f3f Switch to absolute winding values in getWinding()
That’s what the previous code was already doing, but cryptically so. Relates to #1073
2017-02-04 21:38:17 +01:00
Jürg Lehni
0e8b304715 Improve handling of quality value in getWinding()
Relates to #1073
2017-02-04 21:37:05 +01:00
Jürg Lehni
bbcfa644d9 Bring back accidentally removed winding object fallback. 2017-02-04 20:50:22 +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
9af936514e Minor code cleanups. 2017-02-04 20:14:35 +01:00
Jürg Lehni
d18fa8bb03 Support multiple gradient offsets at 0
Closes #1241
2017-01-24 18:14:56 -05:00
Jürg Lehni
4833c588e5 Improve comments. 2017-01-24 08:22:03 -05:00
Jürg Lehni
1806b5959e Improve tangent direction handling in isCrossing()
Find unambiguous vectors by taking inception points and “peaks” into account.

Relates to #1073, #1074
2017-01-24 07:50:40 -05:00
Jürg Lehni
a410aafaf2 Remove unused property. 2017-01-24 06:52:27 -05:00
Jürg Lehni
8bbbe149ea More simplifications related to reorientPaths() 2017-01-22 12:08:54 -05:00
Jürg Lehni
f77621f67d Various improvements to new reorient() code
- Merge insideWindings object with operators lookup
- Optimize handling of excluded paths
- Improve contour handling in unite operations
2017-01-22 11:44:40 -05:00
Jürg Lehni
4e215b0eab Unify naming of bezier coordinates in internal calculations. 2017-01-17 12:05:32 +01:00
Jürg Lehni
6e96fd6be5 Replace accidental substitution of Numerical.CURVETIME_EPSILON. 2017-01-17 11:24:33 +01:00
Jürg Lehni
da52f1f685 Remove Numerical.TOLERANCE 2017-01-16 17:48:26 +01:00
Jürg Lehni
13accee9fd Some code optimizations in PathFitter. 2017-01-16 17:47:28 +01:00
Jürg Lehni
12f12da21b Minor code cleanup. 2017-01-15 18:53:23 +01:00
Jürg Lehni
77cb04154a Reduce CURVETIME_EPSILON to 1e-8. 2017-01-15 18:44:02 +01:00
Jürg Lehni
2ca34cddac Prevent rare case where we get excluded intersections without valid curves at the start. 2017-01-15 18:43:47 +01:00
Jürg Lehni
3d4430f8af Improve CurveLocation#equals() to only compare path offsets.
Relying solely on GEOMETRIC_EPSILON when comparing intersections instead of CURVETIME_EPSILON improves reliability.
2017-01-15 18:43:14 +01:00
Jürg Lehni
f996f035ca Rename local epsilon in addCurveIntersections() to fatLineEpsilon. 2017-01-15 18:41:40 +01:00
Jürg Lehni
a101183fba Remove EPSILON constants that are only used in one place in the code.
CLIPPING_EPSILON and WINDING_EPSILON are too specific to be in Numerical.
2017-01-15 11:47:23 +01: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
fa43e28b7a Slightly improve documentation for #1235 2017-01-11 15:16:22 +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
36f5b314d9 Update JSDoc and a minor documentation fix. 2017-01-11 14:45:52 +01:00
Jürg Lehni
9cb45157b9 Use the correct term for renormalization of curve-time after splitting. 2017-01-10 16:51:53 +01:00
Jürg Lehni
acd6b143db Sample winding at t = 0.5 before trying 0.25 at 0.75
This partly reverts commit 50c910b03a.
2017-01-10 13:34:50 +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
50c910b03a Switch back to sampling winding at t = 1/4, 2/4, 3/4
Due to curve-time clamping, this should now be OK.

Relates to #1073
2017-01-06 14:23:27 +01:00
Jürg Lehni
8ba6e19a2c Bring back handling of onPath edge cases in getWinding()
Relates to #1073
2017-01-06 14:22:20 +01:00
Jürg Lehni
1c7d19bba0 Improve getWinding() reliability by clamping curve-time to tMin <= t <= tMax 2017-01-06 14:17:38 +01:00
Jürg Lehni
31aa68b2d1 Some further code cleanup for 3c2588fdec 2017-01-06 14:15:32 +01:00
Jürg Lehni
7583e6ed5f Merge branch 'improved-winding-2' into develop and clean up formatting. 2017-01-06 12:12:43 +01:00
Jürg Lehni
ed38634a80 Improve comments. 2017-01-03 13:41:26 +01:00
Jürg Lehni
4d81a292a2 Return correct values for #rotation and #scaling on items with #applyMatrix = true
While preserving caching for #applyMatrix = false

Relates to #1004, #1177
2017-01-03 13:39:35 +01:00
Jürg Lehni
aa75374406 Bring back caching of Item#rotation and #scaling
But only allow matrix decomposition based properties on items with #applyMatrix = false

Closes #1177, relates to #1004
2017-01-03 13:23:44 +01:00
Jürg Lehni
ede9ef2623 Revert 7dd0b852c8
Relates to https://github.com/paperjs/paper.js/issues/1233#issuecomment-269972157
2017-01-03 00:53:54 +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
0018b69e4d Improve handling of locations with invalid curves in divideLocations() 2017-01-03 00:20:10 +01:00
Jürg Lehni
b743f456b3 Improve handling of changing curves in CurveLocation.
Relates to #1233
2017-01-03 00:08:28 +01:00
Jürg Lehni
468bb04919 Imrpove bi-directional curve-time rescaling in divideLocations()
Closes #1191
2017-01-02 00:32:21 +01:00
Jürg Lehni
e24402542a Improve handling of SymbolItem in#hitTestAll()
Closes #1199
2017-01-01 18:32:45 +01:00
Jürg Lehni
eceb99ea59 Clean up comments. 2016-12-31 13:32:59 +01:00
Jürg Lehni
7651f41c14 Some code cleanup. 2016-12-31 11:33:18 +01:00
Jürg Lehni
f995216f39 Fix handling of self-intersection in PathItem#getIntersections
Closes #1194
2016-12-31 11:30:38 +01:00
Jürg Lehni
928a58b79a Fix accidental global leackage. 2016-12-31 06:52:56 +01:00
Jürg Lehni
87fe0dd7cd Fix typo. 2016-12-31 06:50:08 +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
88453914e5 Make sure overlaps are always returned in correct sequence.
Relates to #1223
2016-12-31 01:09:28 +01:00
Jürg Lehni
aa2e1d753b Implement Path#divideAt(), similar to Curve#divideAt() 2016-12-31 01:07:14 +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
27a2757542 Merge pull request #1209 from iconexperience/patch-3
Fix length comparison in Path.compare()
2016-12-29 10:55:31 +01:00
Jürg Lehni
767a438286 Merge pull request #1210 from sapics/mini-patch
Replace nodejs version 5 to 6 in Travis
2016-12-29 09:34:05 +01:00
Jürg Lehni
b59baeb9aa Fix stroke hit-testing for rounded shape items.
Closes #1207
2016-12-23 23:11:17 +01:00
iconexperience
61df327bc2 Implement improved reorientation of paths, that can also be used by non-crossing boolean operations. 2016-12-17 18:43:48 +01:00
sapics
3f909da253 Fix example in jsdoc 2016-12-10 12:58:56 +09:00
sapics
523251a288 Use Math.SQRT2 instead of Math.sqrt(2) 2016-12-03 17:32:50 +09:00
sapics
8e5b804d6e Fix typo in comment 2016-12-03 17:31:27 +09:00
Jan
1700a326b1 Fix length comparison in compare()
Path.compare() returned a wrong result if one of the paths were empty. This little change fixes the behaviour.
2016-12-02 16:06:18 +01:00
Jürg Lehni
4281800585 Added missing apostrophe.
Closes https://github.com/paperjs/paperjs.org/pull/25
2016-12-01 21:45:38 -05:00
Jürg Lehni
1f822b1faa Merge pull request #1155 from iconexperience/propagateWinding-pythagoras-fix
Use correct value for y 45 degree tangent
2016-11-28 18:50:11 -05:00
Jürg Lehni
63cb7bd536 Merge pull request #1193 from iconexperience/patch-1
Fix two issues in PathItem.compare()
2016-11-22 19:05:06 -05:00
Jürg Lehni
d779789b6f PaperScript: Prevent invalid JavaScript in assignment operators.
Closes #1151
2016-11-20 21:12:02 -05: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
Jan
eef2297935 Fix two issues in compare()
Variable `count` was never initialized, so incrementing resulted in a NaN.
Creating `paths2` failed if `path._children` was `undefined`.
2016-11-04 15:09:28 +01: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
7dd0b852c8 Remove further unneeded GEOMETRIC_EPSILON curve-end checks. 2016-09-24 14:48:42 -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
3eafd5256a Fix omission in recent renaming. 2016-09-24 14:17:20 -04:00
Jürg Lehni
fbb0c59598 Always use un-scaled curve-time in divideLocations()
Fixes #1169
2016-09-23 06:55:12 -04:00
Jürg Lehni
d3ac1b4c94 Prevent CurveLocation#toString() calls in bitwise xor comparison.
See https://twitter.com/juerglehni/status/778962612197453824
2016-09-22 10:44:23 -04:00
Jürg Lehni
dbe3aa42ec Fix typo in error message. 2016-09-22 10:42:47 -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
0af4c5c0f1 Introduce Curve#hasLength() as an optimized check for curve-length.
And use it where it make sense.

Relates to https://github.com/paperjs/paper.js/issues/1109#issuecomment-234352266
2016-09-20 17:59:56 -04:00
Jan
3b8d3cc47d Use Math..SQRT1_2 instead of 0.7071
Makes code easier to understand.
2016-08-31 23:29:35 +02:00
Jan
f160e74936 Use correct value for y 45 degree tangent
I got the pythagoras wrong when I wrote this. The length of the tangent vector is 1, therefore the y component is sqrt(0.5) for 45°. This will not make any difference, but still we should use the correct value.
2016-08-31 10:05:47 +02:00
Jürg Lehni
cecd95e039 SVG: Correctly handle multiple sequential move commands.
Closes #1134
2016-08-07 21:36:03 +02:00
Jürg Lehni
0396446c4c Boolean: Clean up previous fix. 2016-08-07 15:55:27 +02:00
sapics
31690cb6b6 Fix to remove named layer 2016-08-06 11:00:29 +09:00
Jürg Lehni
75a10fb246 Boolean: Clear branch so we start with a new one on the next contour. 2016-08-04 12:21:58 +02:00
Jürg Lehni
79661c35e6 Some code cleanup in View#setViewSize() 2016-08-03 13:33:58 +02:00
Jürg Lehni
91371c1b47 Keep view.bounds in sync during 'resize' events.
Closes #1127
2016-08-03 13:08:08 +02:00
Jürg Lehni
fa3456341c Fix view flickering during window resizes.
Closes #1126
2016-08-01 17:10:00 +02:00
Jürg Lehni
78c5c27bb3 Boolean: More work on new branching code.
It now checks all intersections when there are multiple options first.
2016-07-28 12:14:02 +02:00
Jürg Lehni
f4f4b3472f Minor code optimization. 2016-07-27 22:58:57 +02:00
Jürg Lehni
17cca2984b Boolean: Make sure we're actually comparing multiple intersections. 2016-07-27 22:57:08 +02:00
Jürg Lehni
4c12f1505c Clean up previous commit. 2016-07-27 21:48:55 +02:00
Jürg Lehni
445d8ae22f Boolean: Implement branch structure to be able to go back on traces and try different crossings.
Relates to #1073
2016-07-27 21:40:53 +02:00
Jürg Lehni
c80c13eb9e Remove _closed parameter from PathItem#isClockwise() again. 2016-07-27 19:41:23 +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
aee9a3190d Improve handling of straight closing curves in open path checks. 2016-07-27 19:09:42 +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
a29ada8f23 Rename PathIterator back to PathFlattener. 2016-07-27 14:18:01 +02:00
Jürg Lehni
753b27afe0 Minor code and comments cleanup. 2016-07-27 14:11:58 +02:00
Jürg Lehni
9a49c2141c Two minor fixes in Base. 2016-07-26 10:25:32 +02:00
Jürg Lehni
34c57a47fa Use faster loop to handle prioritize in Base.filter() 2016-07-26 10:20:30 +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
e2e024f8a5 Winding: Don't mix up onPath and onCurve. 2016-07-23 18:50:58 +02:00
Jürg Lehni
31732917c0 Winding: Improve handling of on-curve tangent checks. 2016-07-23 13:30:40 +02:00
Jürg Lehni
27af304414 Improve new getWinding() direction flipping code. 2016-07-22 23:30:36 +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
0b11f9e2dc Allow getWinding() to flip direction when on the path.
Flipping will only occur when the encountered tangent is parallel to the ray. Relates to #1116
2016-07-22 16:50:39 +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
a5d04ef97c Address minor omission in previous commit. 2016-07-22 00:05:21 +02:00
Jürg Lehni
a5a0e90bee Implement PathItem#compare() to support compound-paths.
Still needs testing.
2016-07-21 23:07:01 +02:00
Jürg Lehni
ccac7ec7c5 Implement Path#compare() to compare for geometric equality of shapes.
Use it in boolean operations when handling fully overlapping paths.

Relates to #1109
2016-07-21 20:57:39 +02:00
Jürg Lehni
baf58fb021 Improve documentation of PathItem#getArea() and PathItem#isClockwise() 2016-07-21 15:30:31 +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
fc72c05e69 Add sort parameter to PathItem#reorient()
And improve documentation. Relates to #590, WIP
2016-07-21 13:50:55 +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
Jürg Lehni
a683486ff5 Some code cleanup for previous commits, and shorten boolean tests a bit. 2016-07-20 16:32:21 +02:00
Jan
4c61153bd4 Improve fat line clipping to fix #1088
Only alternate curves in addCurveIntersections() if interval on other curve is not tight enough yet.
2016-07-20 16:32:20 +02:00
Jürg Lehni
f988445dad Boolean: Implement optimization for operands without crossings.
Closes #1113
2016-07-20 16:15:10 +02:00
Jan
3f893c9fb7 Change winding calculation for points on path
Add a winding if the point is on the path and windings canceled each other. See discussion at #1109
2016-07-20 10:47:01 +02:00
Jürg Lehni
1264c2764c Shorten code statement from #1111 2016-07-20 10:29:27 +02:00
Jan
08f633e7e6 Transfer handle when removing segment 2016-07-20 10:05:03 +02:00
Jürg Lehni
f874b927bf Reflect View#zoom through matrix decomposition, and implement additional decomposed properties.
Closes #1107
2016-07-20 00:04:24 +02:00
Jürg Lehni
4d9c0c9f05 Implement CompoundPath#getLength() 2016-07-19 19:09:23 +02:00
Jürg Lehni
08a23e3318 Boolean: Further improve segment sorting approach. 2016-07-19 16:14:46 +02:00
Jürg Lehni
2c8f4f9453 Boolean: Fix sort function to produce correct resutls on all browsers. 2016-07-19 14:55:57 +02:00
Jürg Lehni
0b672cfb62 Merge branch 'new-winding' into develop 2016-07-19 14:27:45 +02:00
Jürg Lehni
59d598f08e Some documentation improvements for previous commit. 2016-07-19 13:14:26 +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
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
ad48e93ee9 SVG: Output 'h' and 'v' commands in #getPathData() 2016-07-18 21:07:30 +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
3f058e6471 Split #resolveCrossings() into #resolveCrossings() and #reorient()
Closes #973
2016-07-18 14:04:51 +02:00
Jürg Lehni
7acb5bee45 Boolean: More refactoring and code simplifications. 2016-07-18 14:02:20 +02:00
Jürg Lehni
e94e872cda Move #getInteriorPoint() to PathItem, and refactor it a bit more. 2016-07-17 23:04:42 +02:00
Jürg Lehni
9b6fdb8952 Optimize #getInteriorPoint() further.
No need for two separate loops as it can all be done in one pass.
2016-07-17 21:08:22 +02:00
Jürg Lehni
fc18f821b1 Implement simplification of #getInteriorPoint()
As suggested by @iconexperience in https://github.com/paperjs/paper.js/issues/1075#issuecomment-233196940
2016-07-17 20:51:53 +02:00
Jürg Lehni
4bb2f7a8fc Revert a row of recent changes that break example in #1091 2016-07-17 20:35:36 +02:00
Jürg Lehni
c9100a2b61 Merge remote-tracking branch 'origin/develop' into new-winding
; Conflicts:
;	src/path/PathItem.Boolean.js
2016-07-17 19:52:20 +02:00
Jürg Lehni
09785a504b Boolean: Further tweak epsilons values.
Thanks to improved winding code, we can now reduce them to the point where the #_validOverlapsOnly hack can be removed altogether without introducing new issues.
2016-07-17 19:38:10 +02:00
Jürg Lehni
fe9acae985 Winding: More code refactoring and documentation. 2016-07-17 19:36:13 +02:00
Jürg Lehni
064cee1629 Boolean: Sort segments to give non-ambiguous segments preference when tracing.
Relates to #1075
2016-07-16 23:55:16 +02:00
Jürg Lehni
91e67887da Winding: Some improvements to comments and documentation. 2016-07-16 20:17:20 +02:00
Jürg Lehni
8513144ae1 Mono-curves: No need to filter out curves with no length any more. 2016-07-16 20:05:25 +02:00
Jürg Lehni
b1037f89f1 Winding: Add back support for open paths.
Includes refactoring of some related code.
2016-07-16 20:01:36 +02:00
Jürg Lehni
7d675dab13 Some minor cleanups. 2016-07-14 18:58:12 +02:00
Jürg Lehni
7da70181cc Move addWinding() into getWinding()
Allowing the reuse of a whole lot of shared variables and leading to some nice simplifications.
2016-07-14 18:53:23 +02:00
Jürg Lehni
cad2858070 Use same naming for prev* variables as elsewhere in boolean code. 2016-07-14 18:02:42 +02:00
Jürg Lehni
acfe6cddeb Boolean: Improve handling of open paths.
Relates to #1089
2016-07-14 10:49:12 +02:00
Jürg Lehni
c2df96c440 Implement CompoundPath#closed. 2016-07-14 10:24:04 +02:00
Jürg Lehni
41dce862d4 Fix CompoundPath#getLastCurve() and improve documentation. 2016-07-14 10:21:11 +02:00
Jürg Lehni
083a2c6e0d Boolean: Prevent rare exception where an encountered segment is not part of a valid path anymore.
Relates to #1091
2016-07-14 09:14:11 +02:00
Jürg Lehni
6ca3bb1c63 Prevent Path#getStrokeBounds() from accidentally modifying segments.
Closes #1102
2016-07-13 18:43:15 +02:00
iconexperience
46ea9da423 Small cleanup in getWinding() 2016-07-13 11:07:12 +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
73fc111b50 SVG: Correctly handle relative "moveto" commands.
Closes #1101
2016-07-11 19:48:17 +02:00
Jürg Lehni
a02f181c00 Release version 0.10.2 2016-07-09 21:04:37 +02:00
Jürg Lehni
9fefa7dbf0 Release version 0.10.1 2016-07-09 17:17:22 +02:00
Jürg Lehni
0b31b5fdc6 Release version 0.10.0 2016-07-09 16:37:39 +02:00
Jürg Lehni
e15de78347 Update JSHint and fix some some hinting errors. 2016-07-09 14:32:01 +02:00
Jürg Lehni
da78e837a1 Simplify Numerical.solveCubic() code by introducing evaluate() closure. 2016-07-09 13:54:02 +02:00
Jürg Lehni
9d6aab3802 Streamline handling of getNormalizationFactor() to share more code.
Based on comments by @hkrish in https://github.com/paperjs/paper.js/pull/1087#issuecomment-231529361
2016-07-09 13:28:50 +02:00
Jürg Lehni
2532f205a7 Prefer native Math.log2(), but support IE through internalized polyfill. 2016-07-09 12:54:17 +02:00
Jürg Lehni
7e3d18f5d4 Further cleanups in Numerical.solveQuadratic() 2016-07-09 01:10:55 +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
90bc4ffecb Merge pull request #1087 from sapics/improve-poly-solve
Improvements to solve polynomials in Numerical.js
2016-07-07 06:39:28 +02:00
Jürg Lehni
866dcb50dd Some tweaks to potentially support strict mode. 2016-07-07 06:21:20 +02:00
Jürg Lehni
f04dd14309 Remove jsdom legacy code. 2016-07-03 14:16:17 +02:00
Jürg Lehni
df8969f1c4 Switch to jsdom v9.4.0 with native DOMParser support.
Closes #1093
2016-07-03 13:39:05 +02:00
Jürg Lehni
45ffc6fb88 Improve Segment constructor to correctly handle undefined values.
Closes #1095
2016-07-03 13:30:56 +02:00
iconexperience
916a712737 Improved and simplified addWinding and getWinding 2016-06-23 07:54:27 +02:00
Jan
f94b4f969b Accidential semicolon in var declaration
I think this is a mistake
2016-06-22 13:10:02 +02:00
sapics
4fd120fab8 Minor optimization in Numerical.js 2016-06-21 08:47:42 +09:00
sapics
645e2c2af3 Revert EPSILON error in solveCubic 2016-06-20 17:27:08 +09:00
sapics
78f65c9fab Improve solveQuadratic and solveCubic by hkrish c-code 2016-06-20 17:13:09 +09:00
sapics
a9cc938967 Fix normalization in solveQuadratic 2016-06-20 13:53:39 +09:00
sapics
bb683c9291 Remove same value solution in solveCubic 2016-06-20 13:52:54 +09:00
Jürg Lehni
ab24f92373 Bring back accidentally removed hit-test optimization in event handling.
See comment.
2016-06-19 11:02:54 +02:00
Jürg Lehni
739788b67e Clean up Event#currentTarget handlig. 2016-06-19 10:55:04 +02:00
Jürg Lehni
cc55991b66 Fix new issue with Emitter unit tests. 2016-06-18 23:14:48 +02:00
Jürg Lehni
f133475405 Implement MouseEvent#currentTarget and document MouseEvent#target.
Relates to #995
2016-06-18 23:06:17 +02:00
Jürg Lehni
f97143d37d Fix jshint issue introduced by a03631f620 2016-06-17 00:50:06 +02:00
Jürg Lehni
a03631f620 Remove MouseEvent#target hitTest() getter magic again.
Relates to #995
2016-06-17 00:42:40 +02:00
Jürg Lehni
74b22266f7 Clean up code from #1082 & #1083 2016-06-16 14:16:48 +02:00
Jürg Lehni
fa0a474ec7 Merge pull request #1083 from iconexperience/solve-cubic
Add check of value range in Curve.solveCubic to improve performance
2016-06-16 14:02:48 +02:00
Jan
7009fc3ea0 Add check of value range in solveCubic
Performance of `Curve.solveCubic()` can be improved by first checking if the specified value is within the curve's value range. If it is outside the range, the expensive call to `Numerical.solveCubic()` is not necessary.
2016-06-16 13:13:16 +02:00
Jan
c217e963b8 Rough bounds checking for _addBounds()
Performance of `_addBounds()` can be improved significantly by performing a rough bounds checking first. This is a cheap way to check if the curve can extend the current min or max values at all. Only if the check is passed, further Only if the current bounds can be extended by the curve's bounds, further calculation needs to be done.
Also, if the values of a curve are sorted, the extrema are simply the start and end point.
2016-06-16 12:46:12 +02:00
Jürg Lehni
827abd21b8 More refactoring for a328f5b04b 2016-06-16 12:07:38 +02:00
Jürg Lehni
e80b2ff043 Some code-cleanup for a328f5b04b 2016-06-16 11:48:29 +02:00
Jürg Lehni
85c680820e No more need for #_getCurves() since it now does the same as #getCurves()
#getCurves() works both on Path and CompoundPath. Relates to #1073, #1075
2016-06-16 11:16:56 +02:00
Jürg Lehni
1a392bb5db Rename monoCurves -> curves where full curves are dealt with now.
For better clarity. Relates to #1073, #1075
2016-06-16 11:15:27 +02:00
iconexperience
a328f5b04b Revamp winding calculation so it can determine the winding in horizontal and vertical direction. Monotonic curves are new only created on demand. 2016-06-16 10:13:10 +02:00
sapics
ff6484ba8c Fix to cover the case when Numerical.solveQuadratic return -1 in Numerical.solveCubic 2016-06-16 14:53:32 +09:00
sapics
c5b4828ace Fix to cover the case when Numerical.solveQuadratic return -1 in path._getMonoCurves culculation 2016-06-16 13:51:44 +09:00
Jan
262b9b388d Make Numerical.solveQuadratic() optimizable for Chrome V8
Little change to help Chrome's V( optimize `Numerical.solveQuadratic()`. In my use case this resulted in an overall performance improvement of about 1.5%. For details see #1078
2016-06-15 14:53:28 +02:00
Jürg Lehni
643df2d46d Add Raster#loaded to reflect the loading state of its image. 2016-06-14 17:08:32 +02:00