Commit graph

5160 commits

Author SHA1 Message Date
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
Jürg Lehni
c378050783 Fix linting error. 2016-06-14 17:02:05 +02:00
Jürg Lehni
2a3945c4a5 Add additional explanation to fix for #995 2016-06-14 16:54:16 +02:00
Jürg Lehni
724bcb2e35 Make sure mouse events propagate to the view while their targets remain consistent.
Closes #995
2016-06-14 16:52:31 +02:00
Jürg Lehni
93e4d81645 Clean up previous fix for #1069 by better handling mouseenter / leave events. 2016-06-14 16:15:50 +02:00
Jürg Lehni
6b3d8ecdfd Add missing semi-colon. 2016-06-14 15:26:08 +02:00
Jürg Lehni
f6b77b7442 Do not change cashed decomposed matrix data when transforming content.
Just clear the cache and force new decomposition on next use, to avoid issues with nested applied transforms.

Closes #1004
2016-06-14 15:16:45 +02:00
sapics
a0b868c1ba Fix indentations 2016-06-14 12:26:28 +09:00
sapics
7b91e41131 Fix variable leak 2016-06-14 12:20:58 +09:00
Jürg Lehni
28543deaf5 Boolean: Handle situations where seg.getNext() can be null.
Closes #1056
2016-06-13 14:17:47 +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
693898a5b1 No more need for two passes of findBestIntersection()
Goodbye strict-mode :)
2016-06-13 12:49:57 +02:00
Jürg Lehni
fbe787dc4d Fix leaked global. 2016-06-13 12:13:42 +02:00
Jürg Lehni
8da82fed19 Mark all segments as visited when processing intersection and subtraction, not just overlaps. 2016-06-13 12:09:17 +02:00
Jürg Lehni
af5a5b5f2d Make findBestIntersection() more strict and improve comments. 2016-06-13 12:08:44 +02:00
Jürg Lehni
94853669f6 Do not complain about open paths if they would not contain an area when closed. 2016-06-13 12:08:04 +02:00
Jürg Lehni
7241edd98a Implement a more refined strategy to handle 'contour' segment in unite boolean operations.
Improvement for the fix in 648beb33e9 for #1054, solves the issues described in https://github.com/paperjs/paper.js/issues/1054#issuecomment-225356983
2016-06-13 11:58:18 +02:00
Jürg Lehni
34c35e26bd Switch to sampling only one location for winding contribution.
Closes #1073
2016-06-13 11:26:02 +02:00
Jürg Lehni
4c94553b81 Minor cleanup. 2016-06-13 09:00:29 +02:00
Jürg Lehni
fc600595a4 Implement improved strategy to handle tangents in CurveLocation#isCrossing()
Relates to #1074
2016-06-13 08:56:45 +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
7404485f96 Simplify isInRange() check a bit.
No need to check against ±180 as that condition will always be met.
2016-06-12 17:43:10 +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
d1f1d7a5f6 Change behavior of PathItem#closePath() to always attempt joining segments.
Add optional tolerance argument, and use it to handle SVG imprecisions.
Closes #1045
2016-06-11 12:43:37 +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
68be3f102e Prevent mousedown events from disturbing mousenter / mouseleave.
Closes #1069
2016-06-11 11:14:19 +02:00
Jürg Lehni
41e4c622a3 Improve fat-line clipping for rare edge cases.
Instead of limiting recursion levels, limit actual call count. Relates to #904
2016-06-10 23:51:56 +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
e7f7d7c5d1 Fix jshint error caused by #1065 2016-06-10 17:28:46 +02:00
Jürg Lehni
2c2542fb2f Remove unique IDs from Color objects. 2016-06-10 16:19:59 +02:00
Jürg Lehni
0d2779dfc5 Docs: Define default value for PathItem#flatten()
And some other minor cleanups.
2016-06-10 14:53:52 +02:00
Jürg Lehni
964d8cf7d6 PaperScript: Only translate == to equals() calls for Point, Size and Color.
Closes #1043
2016-06-10 13:41:36 +02:00
Jürg Lehni
648beb33e9 Take type of boolean operation into account in getWinding()
Relates to #1054
2016-06-10 13:04:57 +02:00
Jürg Lehni
803dfb6bb1 Improve reliability of Curve#isStraight()
Closes #1066
2016-06-10 12:33:44 +02:00
Jürg Lehni
1f4e4f2f60 Implement boolean simplification suggested by @iconexperiene
See https://github.com/paperjs/paper.js/issues/1054#issuecomment-222517963
2016-06-10 12:06:08 +02:00
Jürg Lehni
719392dd2c Merge pull request #1060 from iconexperience/patch-3
Check for prevTime >= tMin and prevTime <= tMax
2016-06-10 12:00:23 +02:00
Jan
e564955501 Correclty implement sorting of intercepts
`Array.sort()` without comparison function does not sort by numeric value, but by unicode characters (103 comes before 93 by this sorting), therefore a simple comparison function is required.
2016-06-07 16:44:42 +02:00
Jan
b735a3ec95 Fix getInteriorPoint()
getInteriorPoint() could return a point outside the path as explained in #1064
This fix excludes curve's start points from intercept detection to prevent double counting, it ensures that all intercepts are collected and the intercepts are sorted by x-value.
2016-06-07 16:11:37 +02:00
Jan
9f93f6ee78 Check for prevTime >= tMin and prevTime <= tMax
Parameter scaling should only be done if the curve was actually split previously. This only happened if prevTime greater tMin and less tMax.
2016-06-01 14:38:44 +02:00
Jürg Lehni
f19d0c8134 Rename GradientStop#rampPoint to #offset 2016-05-31 12:35:44 +02:00
Jürg Lehni
f07927a95e Correctly handle { x: 0, y: 0 } in Raster#getAverageColor()
Closes #1053
2016-05-27 11:42:08 +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
fefb4302e8 Improve Item#_getStrokeMatrix() 2016-05-22 21:23:46 +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
be79a0e504 Cleanup Path#flatten() code. 2016-05-22 17:24:12 +02:00
sapics
78498f4fd5 Add last curve segment point in path.flatten 2016-05-06 13:28:27 +09:00
Jürg Lehni
681d5537b3 Always pass on dictionary object in _serialize()
It is used to determine if ojects can be serialized in compact form.
2016-05-04 18:06:18 -07:00
Jürg Lehni
4f65996d34 Fix #1032: Correctly handle lastPoint in first mousemove.
Improve first attempt of a fix in e054b760ed
2016-04-13 15:52:59 -07:00
Jürg Lehni
e0a0cd58d5 PaperScript: Improve tool detection code.
And implement Multiple Tools example.
2016-04-13 15:21:35 -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
345730f634 Merge pull request #1002 from sapics/curve-divide
Call curve._changed at curve.divideAtTime
2016-04-06 20:24:55 -07:00
Jürg Lehni
ff82e43d2f Fix GradientStop support in SVG export.
Closes #1027
2016-04-06 20:17:13 -07:00
Jürg Lehni
84421abbce Set crossOrigin before src on image objects.
Reason: https://bugs.chromium.org/p/chromium/issues/detail?id=341047
2016-04-05 12:25:24 -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
093227be7e Fix leaked global variable. 2016-04-04 23:38:37 -07:00
Jürg Lehni
ae9ff56260 Improve check for local URLs in paper.resolvePath() 2016-04-04 23:30:53 -07:00
Jürg Lehni
7cf844886f Add support for relative (local) URLs on Node.js 2016-04-04 23:26:43 -07:00
Jürg Lehni
f4e4e7ab9c Switch to jsdom v8.3.0, now that it includes our node-canvas PR.
See https://github.com/tmpvar/jsdom/pull/1366
2016-04-04 17:55:43 -07:00
Jürg Lehni
20fc3b9f0f Optimize Curve.getArea() to use less operators.
As proposed by @iconexperience in https://github.com/paperjs/paper.js/issues/994#issuecomment-189946135, rearranged for mathematical symmetry.
Closes #994
2016-03-28 08:17:27 -07:00
Jürg Lehni
fc03e042f9 Some minor code and comment cleanup. 2016-03-28 07:59:55 -07:00
Jürg Lehni
e054b760ed Fix cases where toolPoint was null. 2016-03-27 21:41:22 -07:00
Jürg Lehni
1a0c15f177 Fix #1021: use Item#getStyle() to use correct parent style in CompoundPath bounds calculations. 2016-03-27 13:39:30 -07:00
Jürg Lehni
3b71de9544 Fix #980: Implement visual selection of item.position 2016-03-17 14:15:28 +01:00
Jürg Lehni
00b2102b6d More clean-up of selection handling refactoring. 2016-03-17 13:36:02 +01:00
Jürg Lehni
336bc1092e Replace Item#_boundsSelected with #_selectBounds
Plus some refactoring.
2016-03-17 13:09:02 +01:00
Jürg Lehni
f0edcd31b0 Fix #769: Implement Item#selection flags to separate selection from item and bounds. 2016-03-17 13:02:26 +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
6cd36f5460 Fix #1001: Convert absolute local gradient URLs back to relative ones. 2016-03-17 09:48:43 +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
0e658da104 SVG Import: Improve style inheritance in nested <defs> 2016-03-16 20:47:57 +01:00
Jürg Lehni
ca76c1d24f Fix #1009: Make sure all name lookup structures are kept in sync for layers too. 2016-03-16 09:56:10 +01:00
Jürg Lehni
84d2a2f908 SVG Import: Fix issues with viewBox. 2016-03-15 19:00:35 +01:00
Jürg Lehni
484d696df3 Fix #1008: Remove use of ActiveXObject in Http.request() 2016-03-14 19:40:46 +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
af1c481523 Correctly handle trailing slashes in XML attribute namespaces.
See #984
2016-03-14 18:31:45 +01:00
sapics
60f1e78889 Call curve._changed at curve.divideAtTime 2016-03-05 12:23:02 +09:00
Jürg Lehni
7dd110f5b2 Simplify Path#getArea()
Relates to #994
2016-02-26 17:49:44 +01:00
Jürg Lehni
1db419a87b Rename SegmentSelection related internal objects and properties.
Relates to #769, #980
2016-02-26 16:31:50 +01:00
Jürg Lehni
08bf7bfe60 Fix #995: Improve handling of event propagation on View and Item. 2016-02-26 15:13:49 +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
9f90659fdb Fix #991: Make sure items get fully removed in removeChildren() 2016-02-23 11:59:59 +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
acb1e408d0 SVG Import: Fix namespacing issues introduced by #984 2016-02-19 23:30:54 +01:00
Jürg Lehni
b71e3a44d9 Fix #981: Make sure event.delta is always calculated correctly.
The first mousemove / mousedrag events wrongly received the delta from the last mouseup event.
2016-02-19 13:49:06 +01:00
aschmi
49104c5cf0 Add trailing slashes to svg related namespaces (xmlns, xlink) 2016-02-18 16:08:12 +01:00
aschmi
a4757b37de Extend mapping of attribute names to required namespaces 2016-02-18 16:07:56 +01:00
Jürg Lehni
b5c837bb87 Fix #982: Make sure self points to the global scope on Webpack. 2016-02-17 19:06:29 +01:00
Jürg Lehni
6df4602b2b Fix #977: Implement unit-tests. 2016-02-16 20:52:07 +01:00
Jürg Lehni
4081afb635 Fix #977: Apply hit-testing tolerance to fills in Shape. 2016-02-16 00:28:04 +01:00
Jürg Lehni
6975690824 SVG Export: Do not filter out empty paths. 2016-02-16 00:06:26 +01:00
Jürg Lehni
7f48486163 Merge pull request #976 from iconexperience/patch-2
Fix #974 - Keep empty clip mask in SVG export
2016-02-16 00:01:36 +01:00
Jürg Lehni
c35814f94f Node.js: Fix bug when using paper-core.js
And improve Node.js examples. Closes #975
2016-02-15 23:59:31 +01:00
Jürg Lehni
16a7baa967 SvgImport: Fix issues introduced in 6f4890c63c 2016-02-15 23:58:40 +01:00
Jan
b5b1aa57d7 Keep empty clip mask in SVG export
A path should be exported in SVG if it serves as a clip mask, otherwise all items in the clip group that were hidden by clipping in paper.js become visible in the SVG.
2016-02-15 15:29:19 +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
21033f7850 Implement PathItem.create(pathData)
determining if the data describes a plain path or a compound-path with multiple sub-paths.
2016-02-14 23:16:22 +01:00
Jürg Lehni
9f9222f416 List all supported events in event methods on View. 2016-02-14 23:04:48 +01:00
Jürg Lehni
3c3c8d98b0 Document options.insert in #importSVG() 2016-02-14 22:54:33 +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
4c72d9866f Merge pull request #971 from iconexperience/fix-issue-968
Fix for #968 - Improve handling of points on paths in getWinding()
2016-02-14 22:06:55 +01:00
Jürg Lehni
55e7689186 Fix regression introduced in 4e7fa2f04e 2016-02-14 21:55:26 +01:00
Jan
406e6c95b9 Adjust comments to match new implementation 2016-02-14 21:44:34 +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
iconexperience
e2eaf87fcb Improve handling of points on paths in getWinding() 2016-02-14 20:57:24 +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
75c40babc9 SvgImport: Implement support for onLoad and onError callbacks on string input.
Closes #827
2016-02-14 15:12:52 +01:00
Jürg Lehni
2025bd1a77 SvgImport: Implement onError() callback
Closes #969
2016-02-14 14:52:37 +01:00
Jürg Lehni
79d446136a Clean up PR #931
Closes #930
2016-02-14 14:15:17 +01:00
Jürg Lehni
9c9f40d05a Merge pull request #931 from sapics/path-arc
Fix path.arcTo error
2016-02-14 14:11:52 +01:00
Evgeniy Malyarov
add28666cf Update Path.js
fix getNearestPoint error on uninserted curves
; Conflicts:
;	src/path/Path.js
2016-02-14 14:03:54 +01:00
Evgeniy Malyarov
fb76065242 Update Curve.js
fix getNearestPoint error on uninserted curves
2016-02-14 14:03:00 +01:00
Jürg Lehni
e6f43da22b Fix various issues with scaling of shadows.
Supports browser-zoom, HiDPI canvas and view zoom.
Closes #831
2016-02-14 13:49:40 +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
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
e35a55fe66 Flip Matrix properties #b and#c
Their definition was reversed from almost all other Matrix implementations I've encountered.
2016-02-14 10:53:10 +01:00
Jürg Lehni
40d0fca9d0 Fix issue with item bounds permanently collapsing to 0 when applying non-invertible transformations.
We have to keep a backup of the last invertible state around.
Fixes #558 rather elegantly.
2016-02-14 10:44:41 +01:00
Jürg Lehni
dbd7a90e23 Better detect code that requires a tool object.
Closes #967
2016-02-14 01:45:16 +01:00
Jürg Lehni
27197bd156 Docs: Fix warning about isFlatEnough() 2016-02-13 23:32:29 +01:00
Jürg Lehni
0a6efe10f5 Give Tool a paperscript example.
Closes #967
2016-02-13 23:31:54 +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
0a196daa21 Clean-up previous commit. 2016-02-12 21:23:47 +01:00
Jürg Lehni
c6bcf4351a Implement consistent checks for fill / stroke / shadow styles in test functions on Style class.
And use them in Item#_setStyles()
2016-02-12 21:22:30 +01:00
Jürg Lehni
e38829eb96 Support drawing shadows with no shadowBlur.
Closes #955
2016-02-12 21:05:05 +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
Jürg Lehni
7c24fc916f Merge pull request #962 from iconexperience/fix-issue-960
Fix for #960 - Shortcut Curve.evaluate() for t === 1
2016-02-12 20:10:21 +01:00
Jürg Lehni
6d5d1ce077 Introduce Base.filter(), to copy and filter object properties. 2016-02-12 19:58:32 +01:00
Jürg Lehni
06d6b5195b Do not cancel mousedrag events on stopPropagation()
Use preventDefault() instead.
Closes #952
2016-02-12 19:01:34 +01:00
Jürg Lehni
12f829c107 Part 2 of large refactoring of bounds handling. 2016-02-12 18:54:06 +01:00
Jürg Lehni
55c5f42716 Part 1 of large refactoring of bounds handling. 2016-02-12 17:59:37 +01:00
iconexperience
aa1f2196c9 Shortcut Curve.evaluate() for t === 1 to avoid imprecision. 2016-02-12 14:41:21 +01:00
Jürg Lehni
6797d2eb11 Respect clip-items in Group#_getBounds()
Closes #956
2016-02-11 12:51:04 +01:00
Jürg Lehni
68c4541844 SvgImport: Always create a clip-item when viewBox is specified. 2016-02-11 12:50:08 +01:00
Jürg Lehni
e38a33fd64 SVGImport: Inherit default styles on Node.js too. 2016-02-11 11:20:32 +01:00
Jürg Lehni
df57c4adb9 SVGImport: Improve consistency of style handling. 2016-02-11 11:06:09 +01:00