paper 0.17.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +199 -0
- package/LICENSE.txt +1 -1
- package/MIGRATION.md +402 -0
- package/README.md +137 -143
- package/dist/esm/anim/Tween.js +404 -0
- package/dist/esm/basic/Line.js +252 -0
- package/dist/esm/basic/Matrix.js +603 -0
- package/dist/esm/basic/Point.js +738 -0
- package/dist/esm/basic/Rectangle.js +788 -0
- package/dist/esm/basic/Size.js +368 -0
- package/dist/esm/boolean/graph.js +950 -0
- package/dist/esm/boolean/index.js +143 -0
- package/dist/esm/boolean/operations.js +94 -0
- package/dist/esm/boolean/split.js +89 -0
- package/dist/esm/canvas/blendModes.js +115 -0
- package/dist/esm/canvas/canvasProvider.js +102 -0
- package/dist/esm/constants.js +130 -0
- package/dist/esm/core/Base.js +52 -0
- package/dist/esm/core/Emitter.js +215 -0
- package/dist/esm/core/features.js +53 -0
- package/dist/esm/core/serialization.js +174 -0
- package/dist/esm/core.js +15 -0
- package/dist/esm/dom/domElement.js +112 -0
- package/dist/esm/dom/domEvent.js +106 -0
- package/dist/esm/env.js +66 -0
- package/dist/esm/event/DrawEvent.js +38 -0
- package/dist/esm/event/Event.js +79 -0
- package/dist/esm/event/Key.js +236 -0
- package/dist/esm/event/KeyEvent.js +39 -0
- package/dist/esm/event/MouseEvent.js +91 -0
- package/dist/esm/hosted/HostItem.js +60 -0
- package/dist/esm/hosted/Hosting.js +1061 -0
- package/dist/esm/hosted/index.js +20 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/internal.js +115 -0
- package/dist/esm/item/Effect.js +256 -0
- package/dist/esm/item/EffectInstance.js +184 -0
- package/dist/esm/item/Group.js +293 -0
- package/dist/esm/item/HitResult.js +126 -0
- package/dist/esm/item/Item.js +3339 -0
- package/dist/esm/item/ItemDefinition.js +95 -0
- package/dist/esm/item/Layer.js +69 -0
- package/dist/esm/item/Project.js +1013 -0
- package/dist/esm/item/Raster.js +722 -0
- package/dist/esm/item/Shape.js +355 -0
- package/dist/esm/item/SymbolDefinition.js +68 -0
- package/dist/esm/item/SymbolItem.js +131 -0
- package/dist/esm/item/bounds.js +324 -0
- package/dist/esm/item/draw.js +525 -0
- package/dist/esm/item/effects.js +124 -0
- package/dist/esm/item/expand.js +87 -0
- package/dist/esm/item/hitTest.js +203 -0
- package/dist/esm/item/hosting.js +12 -0
- package/dist/esm/item/props.js +12 -0
- package/dist/esm/item/query.js +139 -0
- package/dist/esm/item/sampling.js +67 -0
- package/dist/esm/item/transform.js +128 -0
- package/dist/esm/net/http.js +26 -0
- package/dist/esm/node/CanvasAdapter.js +137 -0
- package/dist/esm/node/index.js +150 -0
- package/dist/esm/node/peers.js +27 -0
- package/dist/esm/offset/curves.js +866 -0
- package/dist/esm/offset/index.js +70 -0
- package/dist/esm/offset/offset.js +178 -0
- package/dist/esm/offset/outline.js +91 -0
- package/dist/esm/offset/pen.js +298 -0
- package/dist/esm/offset/profile.js +772 -0
- package/dist/esm/offset/round.js +213 -0
- package/dist/esm/offset/sweep.js +100 -0
- package/dist/esm/paperscript/PaperScript.js +832 -0
- package/dist/esm/paperscript/autoload.js +27 -0
- package/dist/esm/paperscript/index.js +17 -0
- package/dist/esm/path/CompoundPath.js +367 -0
- package/dist/esm/path/Curve.js +996 -0
- package/dist/esm/path/CurveLocation.js +462 -0
- package/dist/esm/path/Path.js +1761 -0
- package/dist/esm/path/PathFlattener.js +186 -0
- package/dist/esm/path/PathItem.js +757 -0
- package/dist/esm/path/Segment.js +640 -0
- package/dist/esm/path/SegmentPoint.js +106 -0
- package/dist/esm/path/StrokeProfile.js +387 -0
- package/dist/esm/path/StrokeProfileStop.js +207 -0
- package/dist/esm/path/boolean.js +284 -0
- package/dist/esm/path/bounds.js +257 -0
- package/dist/esm/path/crossing.js +114 -0
- package/dist/esm/path/draw.js +161 -0
- package/dist/esm/path/hitTest.js +259 -0
- package/dist/esm/path/offset.js +152 -0
- package/dist/esm/path/shapes.js +231 -0
- package/dist/esm/path/smooth.js +84 -0
- package/dist/esm/path/values.js +40 -0
- package/dist/esm/scope/PaperScope.js +288 -0
- package/dist/esm/scope/PaperScopeItem.js +74 -0
- package/dist/esm/smoothing/index.js +71 -0
- package/dist/esm/style/Color.js +917 -0
- package/dist/esm/style/Gradient.js +191 -0
- package/dist/esm/style/GradientStop.js +168 -0
- package/dist/esm/style/PatternDefinition.js +383 -0
- package/dist/esm/style/Style.js +503 -0
- package/dist/esm/svg/index.js +27 -0
- package/dist/esm/svg/svgElement.js +97 -0
- package/dist/esm/svg/svgExport.js +847 -0
- package/dist/esm/svg/svgImport.js +1101 -0
- package/dist/esm/svg/svgStyles.js +96 -0
- package/dist/esm/text/AreaText.js +190 -0
- package/dist/esm/text/PathText.js +111 -0
- package/dist/esm/text/PointText.js +92 -0
- package/dist/esm/text/TextItem.js +538 -0
- package/dist/esm/text/TextRange.js +169 -0
- package/dist/esm/text/TextStory.js +394 -0
- package/dist/esm/text/areaLayout.js +439 -0
- package/dist/esm/text/layout.js +265 -0
- package/dist/esm/text/measure.js +57 -0
- package/dist/esm/text/pathLayout.js +93 -0
- package/dist/esm/tool/Tool.js +284 -0
- package/dist/esm/tool/ToolEvent.js +232 -0
- package/dist/esm/util/Formatter.js +57 -0
- package/dist/esm/util/collisions.js +216 -0
- package/dist/esm/util/list.js +110 -0
- package/dist/esm/util/numerical.js +656 -0
- package/dist/esm/util/object.js +81 -0
- package/dist/esm/util/string.js +29 -0
- package/dist/esm/util/uid.js +31 -0
- package/dist/esm/values/arcs.js +243 -0
- package/dist/esm/values/curve.js +975 -0
- package/dist/esm/values/fit.js +290 -0
- package/dist/esm/values/index.js +23 -0
- package/dist/esm/values/intersections.js +869 -0
- package/dist/esm/values/matrix.js +114 -0
- package/dist/esm/values/path.js +174 -0
- package/dist/esm/values/profile.js +221 -0
- package/dist/esm/values/region.js +63 -0
- package/dist/esm/values/smooth.js +248 -0
- package/dist/esm/values/svg.js +287 -0
- package/dist/esm/view/CanvasView.js +106 -0
- package/dist/esm/view/View.js +775 -0
- package/dist/esm/view/input.js +527 -0
- package/dist/paper-full.js +32941 -26371
- package/dist/paper-full.min.js +36 -31
- package/dist/paper-hosted.js +33623 -27236
- package/dist/paper-hosted.min.js +37 -0
- package/dist/paper-slim.js +28581 -0
- package/dist/paper-slim.min.js +17 -0
- package/dist/types/anim/Tween.d.ts +164 -0
- package/dist/types/basic/Line.d.ts +136 -0
- package/dist/types/basic/Matrix.d.ts +387 -0
- package/dist/types/basic/Point.d.ts +781 -0
- package/dist/types/basic/Rectangle.d.ts +550 -0
- package/dist/types/basic/Size.d.ts +457 -0
- package/dist/types/boolean/graph.d.ts +123 -0
- package/dist/types/boolean/index.d.ts +74 -0
- package/dist/types/boolean/operations.d.ts +9 -0
- package/dist/types/boolean/split.d.ts +19 -0
- package/dist/types/canvas/blendModes.d.ts +18 -0
- package/dist/types/canvas/canvasProvider.d.ts +32 -0
- package/dist/types/constants.d.ts +112 -0
- package/dist/types/core/Base.d.ts +50 -0
- package/dist/types/core/Emitter.d.ts +49 -0
- package/dist/types/core/features.d.ts +41 -0
- package/dist/types/core/serialization.d.ts +44 -0
- package/dist/types/core.d.ts +18 -0
- package/dist/types/dom/domElement.d.ts +33 -0
- package/dist/types/dom/domEvent.d.ts +29 -0
- package/dist/types/env.d.ts +26 -0
- package/dist/types/event/DrawEvent.d.ts +27 -0
- package/dist/types/event/Event.d.ts +47 -0
- package/dist/types/event/Key.d.ts +82 -0
- package/dist/types/event/KeyEvent.d.ts +35 -0
- package/dist/types/event/MouseEvent.d.ts +78 -0
- package/dist/types/hosted/HostItem.d.ts +26 -0
- package/dist/types/hosted/Hosting.d.ts +273 -0
- package/dist/types/hosted/index.d.ts +10 -0
- package/dist/types/index.d.ts +64 -0
- package/dist/types/internal.d.ts +101 -0
- package/dist/types/item/Effect.d.ts +128 -0
- package/dist/types/item/EffectInstance.d.ts +81 -0
- package/dist/types/item/Group.d.ts +225 -0
- package/dist/types/item/HitResult.d.ts +94 -0
- package/dist/types/item/Item.d.ts +2927 -0
- package/dist/types/item/ItemDefinition.d.ts +25 -0
- package/dist/types/item/Layer.d.ts +80 -0
- package/dist/types/item/Project.d.ts +748 -0
- package/dist/types/item/Raster.d.ts +431 -0
- package/dist/types/item/Shape.d.ts +219 -0
- package/dist/types/item/SymbolDefinition.d.ts +98 -0
- package/dist/types/item/SymbolItem.d.ts +92 -0
- package/dist/types/item/bounds.d.ts +56 -0
- package/dist/types/item/draw.d.ts +23 -0
- package/dist/types/item/effects.d.ts +22 -0
- package/dist/types/item/expand.d.ts +7 -0
- package/dist/types/item/hitTest.d.ts +10 -0
- package/dist/types/item/hosting.d.ts +20 -0
- package/dist/types/item/props.d.ts +35 -0
- package/dist/types/item/query.d.ts +14 -0
- package/dist/types/item/sampling.d.ts +5 -0
- package/dist/types/item/transform.d.ts +3 -0
- package/dist/types/net/http.d.ts +6 -0
- package/dist/types/node/CanvasAdapter.d.ts +19 -0
- package/dist/types/node/index.d.ts +60 -0
- package/dist/types/node/peers.d.ts +2 -0
- package/dist/types/offset/curves.d.ts +22 -0
- package/dist/types/offset/index.d.ts +65 -0
- package/dist/types/offset/offset.d.ts +18 -0
- package/dist/types/offset/outline.d.ts +14 -0
- package/dist/types/offset/pen.d.ts +36 -0
- package/dist/types/offset/profile.d.ts +37 -0
- package/dist/types/offset/round.d.ts +18 -0
- package/dist/types/offset/sweep.d.ts +44 -0
- package/dist/types/paperscript/PaperScript.d.ts +114 -0
- package/dist/types/paperscript/autoload.d.ts +1 -0
- package/dist/types/paperscript/index.d.ts +7 -0
- package/dist/types/path/CompoundPath.d.ts +183 -0
- package/dist/types/path/Curve.d.ts +567 -0
- package/dist/types/path/CurveLocation.d.ts +164 -0
- package/dist/types/path/Path.d.ts +1361 -0
- package/dist/types/path/PathFlattener.d.ts +48 -0
- package/dist/types/path/PathItem.d.ts +1190 -0
- package/dist/types/path/Segment.d.ts +335 -0
- package/dist/types/path/SegmentPoint.d.ts +1 -0
- package/dist/types/path/StrokeProfile.d.ts +74 -0
- package/dist/types/path/StrokeProfileStop.d.ts +110 -0
- package/dist/types/path/boolean.d.ts +24 -0
- package/dist/types/path/bounds.d.ts +24 -0
- package/dist/types/path/crossing.d.ts +2 -0
- package/dist/types/path/draw.d.ts +6 -0
- package/dist/types/path/hitTest.d.ts +8 -0
- package/dist/types/path/offset.d.ts +14 -0
- package/dist/types/path/shapes.d.ts +20 -0
- package/dist/types/path/smooth.d.ts +18 -0
- package/dist/types/path/values.d.ts +8 -0
- package/dist/types/scope/PaperScope.d.ts +182 -0
- package/dist/types/scope/PaperScopeItem.d.ts +26 -0
- package/dist/types/smoothing/index.d.ts +26 -0
- package/dist/types/style/Color.d.ts +829 -0
- package/dist/types/style/Gradient.d.ts +130 -0
- package/dist/types/style/GradientStop.d.ts +126 -0
- package/dist/types/style/PatternDefinition.d.ts +185 -0
- package/dist/types/style/Style.d.ts +757 -0
- package/dist/types/svg/index.d.ts +14 -0
- package/dist/types/svg/svgElement.d.ts +32 -0
- package/dist/types/svg/svgExport.d.ts +19 -0
- package/dist/types/svg/svgImport.d.ts +13 -0
- package/dist/types/svg/svgStyles.d.ts +20 -0
- package/dist/types/text/AreaText.d.ts +104 -0
- package/dist/types/text/PathText.d.ts +78 -0
- package/dist/types/text/PointText.d.ts +50 -0
- package/dist/types/text/TextItem.d.ts +163 -0
- package/dist/types/text/TextRange.d.ts +98 -0
- package/dist/types/text/TextStory.d.ts +119 -0
- package/dist/types/text/areaLayout.d.ts +3 -0
- package/dist/types/text/layout.d.ts +43 -0
- package/dist/types/text/measure.d.ts +7 -0
- package/dist/types/text/pathLayout.d.ts +3 -0
- package/dist/types/tool/Tool.d.ts +356 -0
- package/dist/types/tool/ToolEvent.d.ts +134 -0
- package/dist/types/util/Formatter.d.ts +34 -0
- package/dist/types/util/collisions.d.ts +77 -0
- package/dist/types/util/list.d.ts +23 -0
- package/dist/types/util/numerical.d.ts +196 -0
- package/dist/types/util/object.d.ts +19 -0
- package/dist/types/util/string.d.ts +12 -0
- package/dist/types/util/uid.d.ts +7 -0
- package/dist/types/values/arcs.d.ts +10 -0
- package/dist/types/values/curve.d.ts +42 -0
- package/dist/types/values/fit.d.ts +26 -0
- package/dist/types/values/index.d.ts +10 -0
- package/dist/types/values/intersections.d.ts +11 -0
- package/dist/types/values/matrix.d.ts +19 -0
- package/dist/types/values/path.d.ts +26 -0
- package/dist/types/values/profile.d.ts +41 -0
- package/dist/types/values/region.d.ts +13 -0
- package/dist/types/values/smooth.d.ts +39 -0
- package/dist/types/values/svg.d.ts +47 -0
- package/dist/types/view/CanvasView.d.ts +37 -0
- package/dist/types/view/View.d.ts +700 -0
- package/dist/types/view/input.d.ts +28 -0
- package/package.json +89 -59
- package/dist/docs/assets/css/docs.css +0 -414
- package/dist/docs/assets/js/codemirror.js +0 -4
- package/dist/docs/assets/js/docs.js +0 -493
- package/dist/docs/assets/js/jquery.js +0 -6
- package/dist/docs/assets/js/paper.js +0 -27591
- package/dist/docs/classes/AreaText.html +0 -9186
- package/dist/docs/classes/ChangeFlag.html +0 -385
- package/dist/docs/classes/Color.html +0 -2402
- package/dist/docs/classes/CompoundPath.html +0 -10018
- package/dist/docs/classes/Curve.html +0 -2326
- package/dist/docs/classes/CurveLocation.html +0 -673
- package/dist/docs/classes/DrawEvent.html +0 -69
- package/dist/docs/classes/Effect.html +0 -434
- package/dist/docs/classes/EffectInstance.html +0 -304
- package/dist/docs/classes/Event.html +0 -177
- package/dist/docs/classes/Gradient.html +0 -241
- package/dist/docs/classes/GradientStop.html +0 -274
- package/dist/docs/classes/Group.html +0 -7688
- package/dist/docs/classes/HitResult.html +0 -241
- package/dist/docs/classes/HostItem.html +0 -7314
- package/dist/docs/classes/Item.html +0 -7427
- package/dist/docs/classes/Key.html +0 -140
- package/dist/docs/classes/KeyEvent.html +0 -309
- package/dist/docs/classes/Layer.html +0 -7671
- package/dist/docs/classes/Matrix.html +0 -1745
- package/dist/docs/classes/MouseEvent.html +0 -356
- package/dist/docs/classes/PaperScope.html +0 -548
- package/dist/docs/classes/PaperScript.html +0 -204
- package/dist/docs/classes/Path.html +0 -13007
- package/dist/docs/classes/PathItem.html +0 -9780
- package/dist/docs/classes/PathText.html +0 -9056
- package/dist/docs/classes/PatternDefinition.html +0 -367
- package/dist/docs/classes/Point.html +0 -2860
- package/dist/docs/classes/PointText.html +0 -8967
- package/dist/docs/classes/Project.html +0 -1774
- package/dist/docs/classes/Raster.html +0 -8547
- package/dist/docs/classes/Rectangle.html +0 -1698
- package/dist/docs/classes/Segment.html +0 -1017
- package/dist/docs/classes/Shape.html +0 -8048
- package/dist/docs/classes/Size.html +0 -1915
- package/dist/docs/classes/StrokeProfileStop.html +0 -346
- package/dist/docs/classes/Style.html +0 -1765
- package/dist/docs/classes/SymbolDefinition.html +0 -338
- package/dist/docs/classes/SymbolItem.html +0 -7477
- package/dist/docs/classes/TextItem.html +0 -8810
- package/dist/docs/classes/TextRange.html +0 -186
- package/dist/docs/classes/TextStory.html +0 -355
- package/dist/docs/classes/Tool.html +0 -888
- package/dist/docs/classes/ToolEvent.html +0 -525
- package/dist/docs/classes/Tween.html +0 -390
- package/dist/docs/classes/View.html +0 -2108
- package/dist/docs/classes/global.html +0 -426
- package/dist/docs/classes/index.html +0 -88
- package/dist/docs/index.html +0 -11
- package/dist/node/browser.js +0 -15
- package/dist/node/canvas.js +0 -68
- package/dist/node/extend.js +0 -156
- package/dist/node/self.js +0 -67
- package/dist/paper-core.d.ts +0 -1
- package/dist/paper-core.js +0 -25636
- package/dist/paper-core.min.js +0 -32
- package/dist/paper.d.ts +0 -10481
- package/examples/Animated/AnimatedStar.html +0 -53
- package/examples/Animated/BooleanOperations.html +0 -115
- package/examples/Animated/CandyCrash.html +0 -151
- package/examples/Animated/Extruded.html +0 -50
- package/examples/Animated/Lines.html +0 -53
- package/examples/Animated/Smoothing.html +0 -70
- package/examples/Animated/Space.html +0 -86
- package/examples/Animated/SpaceUsingShapes.html +0 -79
- package/examples/Games/Paperoids.html +0 -569
- package/examples/JSON/Circle Testing.html +0 -34
- package/examples/JSON/Compound Path.html +0 -25
- package/examples/JSON/Empty Path Testing.html +0 -31
- package/examples/JSON/Gradients.html +0 -34
- package/examples/JSON/Group Transform.html +0 -28
- package/examples/JSON/Line Testing.html +0 -44
- package/examples/JSON/Random Path Testing.html +0 -42
- package/examples/JSON/Raster.html +0 -29
- package/examples/JSON/Rect and Attribute Testing.html +0 -56
- package/examples/JSON/Rotated Primitives.html +0 -55
- package/examples/JSON/Selection.html +0 -43
- package/examples/JSON/Shapes.html +0 -54
- package/examples/JSON/Symbols.html +0 -30
- package/examples/JSON/Text Testing.html +0 -38
- package/examples/JSON/Tiger.html +0 -19
- package/examples/JSON/Transform Test 1.html +0 -32
- package/examples/JSON/Transform Test 2.html +0 -30
- package/examples/Node.js/AnimatedStar.js +0 -52
- package/examples/Node.js/BooleanOperations.js +0 -36
- package/examples/Node.js/JSONtoPDF.js +0 -20
- package/examples/Node.js/Raster.js +0 -32
- package/examples/Node.js/RasterRemote.js +0 -33
- package/examples/Node.js/SvgExport.js +0 -52
- package/examples/Node.js/SvgImport.js +0 -23
- package/examples/Node.js/Tadpoles.js +0 -16
- package/examples/Node.js/Tadpoles.pjs +0 -278
- package/examples/Node.js/in.json +0 -1
- package/examples/Node.js/in.svg +0 -16
- package/examples/Paperjs.org/BooleanOperattions.html +0 -115
- package/examples/Paperjs.org/BouncingBalls.html +0 -103
- package/examples/Paperjs.org/Chain.html +0 -54
- package/examples/Paperjs.org/DivisionRaster.html +0 -72
- package/examples/Paperjs.org/FutureSplash.html +0 -122
- package/examples/Paperjs.org/HitTesting.html +0 -103
- package/examples/Paperjs.org/InteractiveTiger.html +0 -777
- package/examples/Paperjs.org/LiveEffects.html +0 -366
- package/examples/Paperjs.org/MetaBalls.html +0 -132
- package/examples/Paperjs.org/NyanRainbow.html +0 -202
- package/examples/Paperjs.org/Offsetting.html +0 -379
- package/examples/Paperjs.org/PathIntersections.html +0 -76
- package/examples/Paperjs.org/Qbertify.html +0 -146
- package/examples/Paperjs.org/RadialRainbows.html +0 -80
- package/examples/Paperjs.org/RoundedRectangles.html +0 -41
- package/examples/Paperjs.org/SatieLikedToDraw.html +0 -140
- package/examples/Paperjs.org/Simplify.html +0 -63
- package/examples/Paperjs.org/SpiralRaster.html +0 -120
- package/examples/Paperjs.org/StrokeProfiles.html +0 -706
- package/examples/Paperjs.org/Tadpoles.html +0 -283
- package/examples/Paperjs.org/Voronoi.html +0 -134
- package/examples/Rasters/PhyllotaxisRaster.html +0 -96
- package/examples/Rasters/Raster.html +0 -34
- package/examples/Rasters/RotationRaster.html +0 -44
- package/examples/Rasters/Smoothing.html +0 -36
- package/examples/SVG Export/Circle Testing.html +0 -32
- package/examples/SVG Export/Clipping.html +0 -17
- package/examples/SVG Export/Compound Path.html +0 -22
- package/examples/SVG Export/Empty Path Testing.html +0 -28
- package/examples/SVG Export/Gradients.html +0 -52
- package/examples/SVG Export/Group Transform.html +0 -25
- package/examples/SVG Export/Line Testing.html +0 -41
- package/examples/SVG Export/Random Path Testing.html +0 -39
- package/examples/SVG Export/Raster.html +0 -21
- package/examples/SVG Export/Rect and Attribute Testing.html +0 -53
- package/examples/SVG Export/Rotated Primitives.html +0 -80
- package/examples/SVG Export/Shapes.html +0 -58
- package/examples/SVG Export/Symbols.html +0 -27
- package/examples/SVG Export/Text Testing.html +0 -45
- package/examples/SVG Export/Tiger.html +0 -23
- package/examples/SVG Export/Transform Test 1.html +0 -29
- package/examples/SVG Export/Transform Test 2.html +0 -27
- package/examples/SVG Import/Arcs.html +0 -78
- package/examples/SVG Import/Butterfly.html +0 -223
- package/examples/SVG Import/Circle and Ellipse Testing.html +0 -26
- package/examples/SVG Import/Clipping.html +0 -100
- package/examples/SVG Import/From File.html +0 -30
- package/examples/SVG Import/Gradient.html +0 -138
- package/examples/SVG Import/Gradients.html +0 -30
- package/examples/SVG Import/Inkscape Pivot.html +0 -52
- package/examples/SVG Import/Inkscape.html +0 -88
- package/examples/SVG Import/Line Testing.html +0 -24
- package/examples/SVG Import/MoreGradients.html +0 -107
- package/examples/SVG Import/Multiple Paths Test 1.html +0 -42
- package/examples/SVG Import/Multiple Paths Test 2.html +0 -33
- package/examples/SVG Import/Nested Groups Test.html +0 -78
- package/examples/SVG Import/Polybezier.html +0 -43
- package/examples/SVG Import/Rect Testing.html +0 -25
- package/examples/SVG Import/Symbols.html +0 -24
- package/examples/SVG Import/Testing.html +0 -40
- package/examples/SVG Import/Text Testing.html +0 -19
- package/examples/SVG Import/Tiger.html +0 -742
- package/examples/SVG Import/Transform Testing.html +0 -22
- package/examples/SVG Import/Viewbox.html +0 -38
- package/examples/Scripts/Arcs.html +0 -39
- package/examples/Scripts/AreaText.html +0 -65
- package/examples/Scripts/BlendModes.html +0 -77
- package/examples/Scripts/BooleanOperations.html +0 -937
- package/examples/Scripts/CompoundPath.html +0 -19
- package/examples/Scripts/CurveTimeParameterization.html +0 -61
- package/examples/Scripts/HslColor.html +0 -53
- package/examples/Scripts/PathStructure.html +0 -82
- package/examples/Scripts/PathTangents.html +0 -73
- package/examples/Scripts/PathText.html +0 -48
- package/examples/Scripts/Patterns.html +0 -57
- package/examples/Scripts/Resize.html +0 -42
- package/examples/Scripts/RoundRectangle.html +0 -28
- package/examples/Scripts/Shapes.html +0 -54
- package/examples/Scripts/StrokeBounds.html +0 -101
- package/examples/Scripts/StrokeScaling.html +0 -65
- package/examples/Scripts/TextRanges.html +0 -51
- package/examples/Tools/BezierTool.html +0 -90
- package/examples/Tools/Circles.html +0 -28
- package/examples/Tools/Clouds.html +0 -35
- package/examples/Tools/DrippingBrush.html +0 -73
- package/examples/Tools/FancyBrush.html +0 -82
- package/examples/Tools/Grid.html +0 -44
- package/examples/Tools/MultiLines.html +0 -44
- package/examples/Tools/MultipleTools.html +0 -44
- package/examples/Tools/PathEditing.html +0 -95
- package/examples/Tools/SquareRounded.html +0 -76
- package/examples/Tools/Stars.html +0 -38
- package/examples/Tools/Vektor.html +0 -200
- package/examples/Tools/Wave.html +0 -50
- package/examples/Tools/WormFarm.html +0 -88
- package/examples/Worker/Main.html +0 -53
- package/examples/Worker/Worker.js +0 -14
- package/examples/css/style.css +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,204 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## `1.0.0-rc.1`
|
|
4
|
+
|
|
5
|
+
### News
|
|
6
|
+
|
|
7
|
+
- Paper.js 1.0 is a rewrite in TypeScript as ES modules, with its own type
|
|
8
|
+
declarations. `MIGRATION.md` lists the changes that can break existing code,
|
|
9
|
+
with the old and the new form side by side.
|
|
10
|
+
- `paper` works as before: import it, call `paper.setup(canvas)` and draw.
|
|
11
|
+
`paper/core` has the classes alone, so bundlers include only what an app uses,
|
|
12
|
+
e.g. 15 KB for `Point` (#1844).
|
|
13
|
+
- `paper/boolean`, `paper/offset` and `paper/smoothing` work on plain path data,
|
|
14
|
+
without items. `paper/node` runs Paper.js on Node.js, `paper/paperscript` adds
|
|
15
|
+
PaperScript, and `paper/hosted` lets an application back projects with its own
|
|
16
|
+
documents, so scripts work on the application's items.
|
|
17
|
+
- Views handle pointer events, so a mouse, pen or finger works the same
|
|
18
|
+
everywhere.
|
|
19
|
+
- Stroke profiles, outlines and offsets are faster and much more robust.
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- Add the entry points `paper/core`, `paper/boolean`, `paper/offset`,
|
|
24
|
+
`paper/smoothing`, `paper/node` and `paper/hosted`, and the script file
|
|
25
|
+
`dist/paper-hosted.js`.
|
|
26
|
+
- Add `use()`, which adds the features that `paper/core` leaves out: boolean
|
|
27
|
+
operations, offsetting, SVG, effects, tweens and rasters.
|
|
28
|
+
- Add the factories `Path.line()`, `Path.circle()`, `Path.rectangle()`,
|
|
29
|
+
`Path.ellipse()`, `Path.arc()`, `Path.regularPolygon()`, `Path.star()`,
|
|
30
|
+
`Shape.circle()`, `Shape.rectangle()` and `Shape.ellipse()`.
|
|
31
|
+
- Add `Item#expand()`, which turns an item into plain items that draw the same,
|
|
32
|
+
as Illustrator's Expand does (#953).
|
|
33
|
+
- Add the options `strokes`, `gradients` and `patterns` to `Item#transform()`.
|
|
34
|
+
- Add `Item#loadSVG()`, `Project#loadSVG()` and `Raster#load()`, which return
|
|
35
|
+
promises.
|
|
36
|
+
- Add `new Color(type, ...components)`, e.g. `new Color('hsb', 0, 1, 1)`.
|
|
37
|
+
- Make `Line` public, with `new Line(from, to)` and an `infinite` property
|
|
38
|
+
(#1589).
|
|
39
|
+
- Add `Curve#getPeaks()` and `Numerical.solveQuartic()`.
|
|
40
|
+
- Keep stroke profiles through boolean operations, `offset()` and
|
|
41
|
+
`interpolate()`, and in SVG files written by Paper.js (#2505, #2506).
|
|
42
|
+
- Let symbol items pass their style on to their definition's content, as SVG's
|
|
43
|
+
`<use>` does (#1329).
|
|
44
|
+
- Add `button`, `buttons`, `pointerType` and `pressure` to mouse and tool events
|
|
45
|
+
(#1354).
|
|
46
|
+
- Add `Tool#onMouseEnter` and `Tool#onMouseLeave` (#1462).
|
|
47
|
+
- Add the canvas attribute `input="off"` for views that ignore the user's input
|
|
48
|
+
(#1491).
|
|
49
|
+
- Support current JavaScript syntax in PaperScript.
|
|
50
|
+
- Add `Effect#interactive`, for effects quick enough to draw while the user
|
|
51
|
+
interacts.
|
|
52
|
+
- Return from `View#dispatchKeyEvent()` whether a handler prevented the default.
|
|
53
|
+
- Document how to subclass items (#1050).
|
|
54
|
+
- Add `PatternDefinition#pitch` and `shift`, which arrange the tiles as
|
|
55
|
+
bricks, e.g. with `shift: [0.5, 0]`, or as hexagons, with
|
|
56
|
+
`pitch: [0.75, 1], shift: [0, 0.5]`.
|
|
57
|
+
- Add `PatternDefinition#rightInFront` and `bottomInFront`, which choose the
|
|
58
|
+
tiles in front where the item reaches beyond its tile.
|
|
59
|
+
- Add `Point.coerce()` and `Size.coerce()`, which read a single number as both
|
|
60
|
+
coordinates, as `point.multiply(2)` and `item.translate(10)` do.
|
|
61
|
+
- Take the coordinates of `cubicCurveTo()`, `quadraticCurveTo()`,
|
|
62
|
+
`cubicCurveBy()` and `quadraticCurveBy()` as numbers, as canvas takes them.
|
|
63
|
+
- Add the `shadow` option to `Item#getBounds()`, which includes the shadows
|
|
64
|
+
of the item and its children.
|
|
65
|
+
|
|
66
|
+
### Changed
|
|
67
|
+
|
|
68
|
+
- Make the package ES modules only, for Node.js 22.22 or later, and let only its
|
|
69
|
+
entries and script files be imported (#2035).
|
|
70
|
+
- Rename `dist/paper-core.js` to `dist/paper-slim.js`.
|
|
71
|
+
- Generate the type declarations from the sources, with `null` where values can
|
|
72
|
+
be missing and unions for fixed sets of strings.
|
|
73
|
+
- Make `Item#name`, `Segment#name`, `Item#children` and `Tool#minDistance` and
|
|
74
|
+
its siblings `null` instead of `undefined`.
|
|
75
|
+
- Return the path from its drawing commands, so calls can be chained (#605).
|
|
76
|
+
- Read and write `Item#pivot` in the parent's coordinates, as `position` is
|
|
77
|
+
(#1272).
|
|
78
|
+
- Return a plain `Rectangle` from `Item#getBounds()` without arguments, and
|
|
79
|
+
booleans from `Item#replaceWith()` and `Matrix#isInvertible()`.
|
|
80
|
+
- Read every argument of `Path#add()` and `#insert()` as a segment.
|
|
81
|
+
- Start rectangles and ellipses where SVG starts them (#601).
|
|
82
|
+
- Keep the items of symbol definitions in place instead of centering them
|
|
83
|
+
(#2435).
|
|
84
|
+
- Make `PathItem#reorient()` take `{ fillRule, clockwise }` and use the item's
|
|
85
|
+
fill rule.
|
|
86
|
+
- Scale strokes and dashes along when an item applies a matrix it kept.
|
|
87
|
+
- Make `offset()`, `outline()` and `dash()` fall back to the item's `width` and
|
|
88
|
+
`dashArray` where these are `null`, and take a `miterLimit` of `0` as given.
|
|
89
|
+
- Outline stroke profiles three times as fast, and offset and outline paths 10%
|
|
90
|
+
faster.
|
|
91
|
+
- Return a promise from `Tween#then()`.
|
|
92
|
+
- Rename text styles to their names in CSS, e.g. `fontFeatures`, `letterCase`
|
|
93
|
+
and `lineWrap`, and default `justification` to `'start'`.
|
|
94
|
+
- Rename `TextItem#range()` and `TextStory#range()` to `getRange()`.
|
|
95
|
+
- Import the layers of SVG files written by Paper.js as layers again (#483).
|
|
96
|
+
- Handle pointer events instead of mouse and touch events; `event.event` is a
|
|
97
|
+
`PointerEvent` (#1354, #1959).
|
|
98
|
+
- Read the characters of key events from `keydown` events.
|
|
99
|
+
- List `Project#selectedItems` in drawing order.
|
|
100
|
+
- Parse PaperScript as a module, and load scripts with `src` through `fetch()`.
|
|
101
|
+
- Run PaperScript through `eval`, so a content security policy has to allow
|
|
102
|
+
`unsafe-eval`.
|
|
103
|
+
- Run the page's PaperScripts only from the script files: with
|
|
104
|
+
`paper/paperscript`, call `PaperScript.load()`.
|
|
105
|
+
- Return promises from `exportFrames()` and `exportImage()` on Node.js.
|
|
106
|
+
- Decide from the environment whether views update by themselves: with a DOM of
|
|
107
|
+
your own on Node.js, set `view.autoUpdate = false`.
|
|
108
|
+
- Stop `paper/hosted` from changing the core classes when it loads, and rename
|
|
109
|
+
the host's `getItem()` to `getContent()`.
|
|
110
|
+
- Stop clipping the item of a pattern by its tile: parts beyond it lie over the
|
|
111
|
+
tiles around it, the left and top ones in front by default.
|
|
112
|
+
- Replace `PatternDefinition#tile` by `size`, which defaults to the item's
|
|
113
|
+
bounds.
|
|
114
|
+
- Clip the content of patterns by their tiles in SVG import, as SVG draws them,
|
|
115
|
+
and write each tile that reaches into a pattern's repeat in SVG export.
|
|
116
|
+
- Throw an error for a single number where a point or size is expected,
|
|
117
|
+
instead of reading it as both coordinates, so calls such as
|
|
118
|
+
`new Segment(10, 20)` fail rather than draw in the wrong place.
|
|
119
|
+
- Leave the `id` of canvases alone: views find themselves from their
|
|
120
|
+
canvases, and no longer write ids such as `paper-view-0` into them.
|
|
121
|
+
- Unite, intersect and subtract several paths at once faster, by about a
|
|
122
|
+
fifth to a third for 5 to 50 paths without stroke profiles.
|
|
123
|
+
- Start the dashes of rounded rectangle and ellipse shapes where those of the
|
|
124
|
+
same paths start, at the top left, as SVG converts rectangles.
|
|
125
|
+
- Create items from their segments, children, path data or other arguments as
|
|
126
|
+
from the same properties, so that `new Path({ x, y, strokeColor })` sets its
|
|
127
|
+
segment before its other properties, as `new Path({ segments, strokeColor })`
|
|
128
|
+
does.
|
|
129
|
+
- Type `selected` only on the points and rectangles that items, segments and
|
|
130
|
+
curves return, which are `SelectablePoint` and `SelectableRectangle`, as
|
|
131
|
+
other points and rectangles can't be selected.
|
|
132
|
+
- Type the properties of `HitResult` that only some kinds of hits have as
|
|
133
|
+
optional: `name`, `location`, `segment` and `point`.
|
|
134
|
+
|
|
135
|
+
### Removed
|
|
136
|
+
|
|
137
|
+
- Remove the getter and setter methods, such as `item.getPosition()`: use the
|
|
138
|
+
properties.
|
|
139
|
+
- Remove argument forms that spread numbers, such as `new Segment(x, y)`, and
|
|
140
|
+
points given as strings.
|
|
141
|
+
- Remove the constructors of predefined paths and shapes, such as
|
|
142
|
+
`new Path.Circle()`: use the factories.
|
|
143
|
+
- Remove `paper.Symbol`, `paper.PlacedSymbol` and the other deprecated APIs,
|
|
144
|
+
listed in `MIGRATION.md`.
|
|
145
|
+
- Remove `Item.extend()`: use `class extends`.
|
|
146
|
+
- Remove `PaperScope#execute()`: use `PaperScript.execute()`.
|
|
147
|
+
- Remove loading files from `importSVG()`: use `loadSVG()`.
|
|
148
|
+
- Remove `settings.scaleStrokes`: use `transform(matrix, { strokes: true })`.
|
|
149
|
+
- Remove `paper.DomEvent`, `paper.DomElement`, `paper.Http` and the undocumented
|
|
150
|
+
static methods of `Curve`, listed in `MIGRATION.md`.
|
|
151
|
+
- Remove support for node-canvas, jsdom and CommonJS, and the `paper-jsdom`
|
|
152
|
+
packages.
|
|
153
|
+
- Remove the key names of Internet Explorer, such as `Spacebar`.
|
|
154
|
+
|
|
155
|
+
### Fixed
|
|
156
|
+
|
|
157
|
+
- Fix slits, spikes, hairlines and other defects in the outlines of strokes and
|
|
158
|
+
stroke profiles.
|
|
159
|
+
- Fix `offset()` of stroke profiles and of paths with tiny handles or no length.
|
|
160
|
+
- Fix boolean operations losing areas, and `divide()` of touching paths.
|
|
161
|
+
- Fix `getIntersections()`, `contains()` and hit-tests at cusps and where paths
|
|
162
|
+
turn back.
|
|
163
|
+
- Fix `arcTo()` and its siblings for straight arcs.
|
|
164
|
+
- Fix object literals for rectangles, and properties left over by the factories.
|
|
165
|
+
- Fix gradient stops without an `offset`, and `Gradient#equals()`.
|
|
166
|
+
- Fix `Segment#reverse()`, `Segment#interpolate()` and evaluating curves at
|
|
167
|
+
locations.
|
|
168
|
+
- Fix the stroke bounds, hit-tests and `interpolate()` of compound paths.
|
|
169
|
+
- Fix pivots after `toShape()`, copies and boolean operations.
|
|
170
|
+
- Fix `Matrix#scale()`, `#shear()` and `#invert()` on the matrix of an item.
|
|
171
|
+
- Fix `raster.width = …`, which lost the raster's content.
|
|
172
|
+
- Fix effects applying the opacity and blend mode of their item twice.
|
|
173
|
+
- Fix `new Path([])`, `Item#addChildren()` of several items, and
|
|
174
|
+
`TextStory#replace()`.
|
|
175
|
+
- Fix selected paths drawn with another scope's settings.
|
|
176
|
+
- Fix SVG import of `<use>` styles (#1329), the styles and rotation of text
|
|
177
|
+
(#2665, #2784), strokes in transformed groups, and empty polygons.
|
|
178
|
+
- Fix nested SVG imports and exports, and exporting items scaled to nothing.
|
|
179
|
+
- Fix repeated `mouseenter` events, and views sharing their state.
|
|
180
|
+
- Fix drags with two mouse buttons (#1355) and mouse moves with pointer lock
|
|
181
|
+
(#1802).
|
|
182
|
+
- Fix `event.modifiers` and the values of tool events, which changed after the
|
|
183
|
+
event.
|
|
184
|
+
- Fix handlers returning `0` or `''` stopping events.
|
|
185
|
+
- Fix PaperScript reading names in comments and strings as globals.
|
|
186
|
+
- Fix the declarations for apps with strict settings.
|
|
187
|
+
- Resolve references to the host's definitions, such as `['@pattern/Dots']`,
|
|
188
|
+
in `importJSON()` of hosted projects, where they stayed arrays and failed
|
|
189
|
+
later, e.g. in a current style with a pattern fill.
|
|
190
|
+
- Name the key in the error when the host of a project has no definition for
|
|
191
|
+
it, instead of failing on `null`.
|
|
192
|
+
- Include shadows in `Item#previewBounds`, so that `Item#rasterize()`, pattern
|
|
193
|
+
tiles and groups with an opacity no longer cut them off.
|
|
194
|
+
- Keep the matrix of groups and compound paths that `Item#reduce()` replaces
|
|
195
|
+
by their single child, which also misplaced the results of boolean
|
|
196
|
+
operations, `outline()` and `dash()` of such compound paths.
|
|
197
|
+
- Fix the bounds of transformed items that keep their matrix, which ignored
|
|
198
|
+
changes to their children.
|
|
199
|
+
- Send the events of canvases that share an `id`, as in different shadow
|
|
200
|
+
roots, to their own views.
|
|
201
|
+
|
|
3
202
|
## `0.17.0`
|
|
4
203
|
|
|
5
204
|
### Added
|
package/LICENSE.txt
CHANGED
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
# Migrating from Paper.js 0.17 to 1.0
|
|
2
|
+
|
|
3
|
+
Paper.js 1.0 is rewritten as ES modules in TypeScript. Most scripts run as they
|
|
4
|
+
are. The main changes are how the library is loaded, properties in place of the
|
|
5
|
+
`getX()` / `setX()` methods, fewer argument forms, and the removal of
|
|
6
|
+
deprecated APIs.
|
|
7
|
+
|
|
8
|
+
This guide lists every change that can break existing code. What is new is in
|
|
9
|
+
the [change log](CHANGELOG.md).
|
|
10
|
+
|
|
11
|
+
## Loading the library
|
|
12
|
+
|
|
13
|
+
The package is ES modules only and needs Node.js 22.22 or later. `paper` works
|
|
14
|
+
as before. The other entries are new, e.g. `paper/core` for smaller bundles,
|
|
15
|
+
see [Package Entries](README.md#package-entries).
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
// 0.17
|
|
19
|
+
const paper = require('paper')
|
|
20
|
+
|
|
21
|
+
// 1.0
|
|
22
|
+
import paper, { Path, Point } from 'paper'
|
|
23
|
+
// or with require(), which returns the module's exports:
|
|
24
|
+
const { default: paper, Path, Point } = require('paper')
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- Only the entries and the script files can be imported; deep imports of
|
|
28
|
+
other files fail.
|
|
29
|
+
- The AMD export is gone.
|
|
30
|
+
- For use without a bundler, the script files set the global `paper` as
|
|
31
|
+
before: `dist/paper-full.js` with PaperScript, `dist/paper-slim.js` without
|
|
32
|
+
it (formerly `paper-core.js`), and `dist/paper-hosted.js`, each also as
|
|
33
|
+
`.min.js`. Instead of `paper/dist/paper-core`, import `paper`.
|
|
34
|
+
- The examples and docs are no longer in the package.
|
|
35
|
+
- The code needs ES2022, as in all current browsers.
|
|
36
|
+
|
|
37
|
+
## Properties instead of getter and setter methods
|
|
38
|
+
|
|
39
|
+
The getter and setter methods of properties are gone. Use the properties, which
|
|
40
|
+
0.17 had too.
|
|
41
|
+
|
|
42
|
+
| 0.17 | 1.0 |
|
|
43
|
+
| ------------------------------------------- | ------------------------------------ |
|
|
44
|
+
| `item.getPosition()`, `item.setPosition(p)` | `item.position`, `item.position = p` |
|
|
45
|
+
| `item.getVisible()` | `item.visible` |
|
|
46
|
+
| `path.getSegments()` | `path.segments` |
|
|
47
|
+
| `point.getLength()`, `point.getX()` | `point.length`, `point.x` |
|
|
48
|
+
| `view.getViewSize()` | `view.viewSize` |
|
|
49
|
+
|
|
50
|
+
- Getters with arguments stay methods, e.g. `item.getBounds(options)` and
|
|
51
|
+
`path.getPointAt(offset)`, and so do predicates, e.g. `point.isZero()`.
|
|
52
|
+
- `Raster#getElement()` becomes the `element` property.
|
|
53
|
+
|
|
54
|
+
## Arguments
|
|
55
|
+
|
|
56
|
+
Points, sizes and rectangles can no longer be spread over several number
|
|
57
|
+
arguments. Pass each as one argument, an object or an array. A single number
|
|
58
|
+
where a point or size is expected throws an error, so the old calls below fail
|
|
59
|
+
instead of reading the number as both coordinates.
|
|
60
|
+
|
|
61
|
+
| 0.17 | 1.0 |
|
|
62
|
+
| ------------------------------------- | --------------------------------------- |
|
|
63
|
+
| `new Segment(10, 20)` | `new Segment([10, 20])` |
|
|
64
|
+
| `item.hitTest(x, y, options)` | `item.hitTest([x, y], options)` |
|
|
65
|
+
| `item.rotate(45, x, y)` | `item.rotate(45, [x, y])` |
|
|
66
|
+
| `new Path.Circle(x, y, radius)` | `Path.circle([x, y], radius)` |
|
|
67
|
+
| `new Rectangle(point, width, height)` | `new Rectangle(point, [width, height])` |
|
|
68
|
+
| `color.add(0.1, 0.2, 0.3)` | `color.add([0.1, 0.2, 0.3])` |
|
|
69
|
+
| `new PointText(x, y)` | `new PointText([x, y])` |
|
|
70
|
+
| `new Point('10, 20')` | `new Point(10, 20)` |
|
|
71
|
+
|
|
72
|
+
`color.add(0.1, 0.2, 0.3)` is the exception: it still runs, and adds `0.1` to
|
|
73
|
+
every component.
|
|
74
|
+
|
|
75
|
+
These stay:
|
|
76
|
+
|
|
77
|
+
- `(x, y)` where a point or size is a method's only argument:
|
|
78
|
+
`path.moveTo(10, 20)`, `point.add(1, 2)`, `item.translate(10, 0)`.
|
|
79
|
+
- The coordinates of curve commands, as canvas takes them:
|
|
80
|
+
`cubicCurveTo(x1, y1, x2, y2, x, y)`, `quadraticCurveTo(x1, y1, x, y)`, and
|
|
81
|
+
their `By` versions.
|
|
82
|
+
- The constructors `new Point(x, y)`, `new Size(width, height)`,
|
|
83
|
+
`new Rectangle(x, y, width, height)` and `new Rectangle(point, size)`.
|
|
84
|
+
- Single numbers for both coordinates in arithmetic, translations, scale
|
|
85
|
+
factors and radii, e.g. `point.multiply(2)`, `item.translate(10)`,
|
|
86
|
+
`item.scale(2)` and `Path.circle(center, 10)`.
|
|
87
|
+
`Point.coerce(2)` and `Size.coerce(2)` read them the same way.
|
|
88
|
+
- The documented pairs `scale(hor, ver, center)`, `shear()`, `skew()`,
|
|
89
|
+
`getPixel(x, y)` and `setPixel(x, y, color)`.
|
|
90
|
+
- Object arguments, e.g. `Path.circle({ center, radius, fillColor })`.
|
|
91
|
+
|
|
92
|
+
Some arguments are read differently:
|
|
93
|
+
|
|
94
|
+
- `path.add()` and `path.insert()` read every argument as a segment, so
|
|
95
|
+
`path.add(10, 20)` throws: pass `path.add([10, 20])`.
|
|
96
|
+
- `path.arcTo(to, radius, rotation, clockwise, large)` reads a number radius as
|
|
97
|
+
both radii, and draws the SVG form whenever a rotation is given.
|
|
98
|
+
- `new Path({ x, y, strokeColor })` makes a segment of `x` and `y` and now
|
|
99
|
+
also sets the other properties.
|
|
100
|
+
|
|
101
|
+
## Factories for paths and shapes
|
|
102
|
+
|
|
103
|
+
Factory methods replace the constructors of predefined paths and shapes.
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
// 0.17
|
|
107
|
+
new Path.Circle({ center: [50, 50], radius: 20 })
|
|
108
|
+
new Shape.Rectangle(rectangle)
|
|
109
|
+
|
|
110
|
+
// 1.0
|
|
111
|
+
Path.circle({ center: [50, 50], radius: 20 })
|
|
112
|
+
Shape.rectangle(rectangle)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The factories are `Path.line()`, `circle()`, `rectangle()`, `ellipse()`,
|
|
116
|
+
`arc()`, `regularPolygon()` and `star()`, and `Shape.circle()`, `rectangle()`
|
|
117
|
+
and `ellipse()`. `Path.RoundRectangle` and `Path.Oval` are gone: use
|
|
118
|
+
`Path.rectangle({ rectangle, radius })` and `Path.ellipse()`.
|
|
119
|
+
|
|
120
|
+
## PaperScript
|
|
121
|
+
|
|
122
|
+
PaperScript is its own entry. `dist/paper-full.js` still includes it.
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
// 0.17: part of the library
|
|
126
|
+
paper.execute(code)
|
|
127
|
+
|
|
128
|
+
// 1.0
|
|
129
|
+
import paper from 'paper'
|
|
130
|
+
import { PaperScript } from 'paper/paperscript'
|
|
131
|
+
PaperScript.execute(code, paper)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- With `dist/paper-full.js`, call `paper.PaperScript.execute(code, paper)`.
|
|
135
|
+
- Importing `paper/paperscript` no longer runs the page's
|
|
136
|
+
`<script type="text/paperscript">` tags. Call `PaperScript.load()` once the
|
|
137
|
+
page has loaded. `dist/paper-full.js` still runs them on its own.
|
|
138
|
+
- Code is parsed as a module, so current JavaScript syntax works and strict
|
|
139
|
+
mode applies: `with` and legacy octals are errors.
|
|
140
|
+
- Scripts with `src` load through `fetch`, asynchronously.
|
|
141
|
+
- Code runs through `eval` in all browsers, so a content security policy has to
|
|
142
|
+
allow `unsafe-eval`. Chrome needed `unsafe-inline` before.
|
|
143
|
+
- The options `handlers` and `load` of `execute()` are now `handlerNames` and
|
|
144
|
+
`importModule`. It returns the script's exports, or a promise of them for
|
|
145
|
+
code with top-level `await`.
|
|
146
|
+
|
|
147
|
+
## Node.js
|
|
148
|
+
|
|
149
|
+
`paper/node` replaces the `paper-jsdom` and `paper-jsdom-canvas` packages. It
|
|
150
|
+
uses happy-dom and `@napi-rs/canvas` instead of jsdom and node-canvas; install
|
|
151
|
+
them alongside.
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
// 0.17
|
|
155
|
+
const paper = require('paper-jsdom-canvas')
|
|
156
|
+
|
|
157
|
+
// 1.0
|
|
158
|
+
import paper, { GlobalFonts } from 'paper/node'
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
- `view.exportFrames()` and `exportImage()` return promises, instead of taking
|
|
162
|
+
an `onComplete` option or a callback.
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
// 0.17
|
|
166
|
+
view.exportImage('out.png', () => console.log('done'))
|
|
167
|
+
|
|
168
|
+
// 1.0
|
|
169
|
+
await view.exportImage('out.png')
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- A view with `onFrame` no longer keeps the process running.
|
|
173
|
+
- node-canvas's PDF and SVG canvases, the stream methods and the `require()`
|
|
174
|
+
hook for `.pjs` files are gone. The README shows how to run PaperScript on
|
|
175
|
+
Node.js.
|
|
176
|
+
- Register fonts with `GlobalFonts`.
|
|
177
|
+
- Views tell from the environment whether to update by themselves. With a DOM of
|
|
178
|
+
your own on Node.js, such as jsdom, set `view.autoUpdate = false`.
|
|
179
|
+
|
|
180
|
+
## Classes
|
|
181
|
+
|
|
182
|
+
`Item.extend()` is gone. Subclass with `class extends`, and register the class
|
|
183
|
+
with `registerClasses()` to import it from JSON.
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
// 0.17
|
|
187
|
+
const Arrow = Path.extend({
|
|
188
|
+
_class: 'Arrow',
|
|
189
|
+
initialize: function (props) {
|
|
190
|
+
Path.call(this, props)
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
// 1.0
|
|
195
|
+
import { Path, registerClasses } from 'paper'
|
|
196
|
+
class Arrow extends Path {}
|
|
197
|
+
registerClasses({ Arrow })
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`paper.Symbol` and `paper.PlacedSymbol`, deprecated since 0.10, are gone: use
|
|
201
|
+
`SymbolDefinition` and `SymbolItem`.
|
|
202
|
+
|
|
203
|
+
## TypeScript
|
|
204
|
+
|
|
205
|
+
The package ships its own declarations instead of `dist/paper.d.ts`. Import the
|
|
206
|
+
classes as types by name, or use them through `paper` as before.
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
// 0.17
|
|
210
|
+
import paper from 'paper'
|
|
211
|
+
let point: paper.Point
|
|
212
|
+
let cap: string = path.strokeCap
|
|
213
|
+
|
|
214
|
+
// 1.0
|
|
215
|
+
import paper, { Point } from 'paper'
|
|
216
|
+
import type { StrokeCap } from 'paper'
|
|
217
|
+
let point: Point // or paper.Point
|
|
218
|
+
let cap: StrokeCap = path.strokeCap
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- The types say where values can be `null`, e.g. `Item#parent`, `Curve#next`,
|
|
222
|
+
`View#element`, and `Path#getPointAt()` off the path. With
|
|
223
|
+
`strictNullChecks`, check for it.
|
|
224
|
+
- Properties that take a fixed set of strings have union types, exported as
|
|
225
|
+
e.g. `StrokeCap`, `StrokeJoin`, `BlendMode` and `FillRule`. A plain
|
|
226
|
+
`string` no longer fits them.
|
|
227
|
+
- `Curve#values` is a tuple of eight numbers.
|
|
228
|
+
- Handlers are typed by their event. The `target` of a view's mouse events is
|
|
229
|
+
an item or the view.
|
|
230
|
+
- `selected` is typed only on the points and rectangles that items, segments
|
|
231
|
+
and curves return, as `SelectablePoint` and `SelectableRectangle`, not on
|
|
232
|
+
every `Point` and `Rectangle`.
|
|
233
|
+
|
|
234
|
+
## Changed behavior
|
|
235
|
+
|
|
236
|
+
**Mouse and tool events**
|
|
237
|
+
|
|
238
|
+
- Views use the DOM's pointer events instead of touch and mouse events, so mice
|
|
239
|
+
and pens work on touch devices too. The event names stay `mousedown`,
|
|
240
|
+
`mousedrag` and so on.
|
|
241
|
+
- `event.event` is a `PointerEvent`, without `touches`. `MouseEvent` and
|
|
242
|
+
`ToolEvent` have their own `button`, `buttons`, `pointerType` and
|
|
243
|
+
`pressure`.
|
|
244
|
+
- Views listen on their own element, not the document, and capture the pointer
|
|
245
|
+
while it is pressed. While nothing is pressed, they no longer see moves outside
|
|
246
|
+
their element.
|
|
247
|
+
- Views no longer give their canvases an `id` such as `paper-view-0`.
|
|
248
|
+
- Items and views get `mouseleave` when a touch on them ends. Views get
|
|
249
|
+
`mouseenter` once on entering, not again after every press and release.
|
|
250
|
+
- `event.modifiers` holds the modifier keys as they were when the event
|
|
251
|
+
happened. `Key.modifiers` still has the current state.
|
|
252
|
+
|
|
253
|
+
**Items and geometry**
|
|
254
|
+
|
|
255
|
+
- `Item#pivot` is in the parent's coordinates, like `position`. This only
|
|
256
|
+
matters for items that keep their matrix (shapes, rasters, symbol items, text,
|
|
257
|
+
`applyMatrix: false`): convert their pivot with `localToGlobal()`.
|
|
258
|
+
- `Item#getBounds()` without arguments returns a plain `Rectangle`. `bounds` and
|
|
259
|
+
`strokeBounds` still return linked ones.
|
|
260
|
+
- Rectangles start at the top left and ellipses at the right, as in SVG, so
|
|
261
|
+
their dashes match exported `<rect>` and `<ellipse>` elements.
|
|
262
|
+
- `PathItem#reorient()` takes options, `reorient({ fillRule, clockwise })`, and
|
|
263
|
+
uses the item's `fillRule` instead of always the even-odd rule:
|
|
264
|
+
`reorient(true)` becomes `reorient({ fillRule: 'nonzero' })`. On an item with
|
|
265
|
+
the default `'nonzero'` rule, `reorient()` becomes
|
|
266
|
+
`reorient({ fillRule: 'evenodd' })` to keep its result. Sub-paths
|
|
267
|
+
that touch or cross are replaced by the outline of the area they fill.
|
|
268
|
+
- Symbol definitions no longer center their items, and the `dontCenter`
|
|
269
|
+
argument is gone. `place(point)` still puts the item's origin at the point.
|
|
270
|
+
- These are `null` instead of `undefined` when not set: `Item#name`,
|
|
271
|
+
`Segment#name`, `Item#children` of items without children, and
|
|
272
|
+
`Tool#minDistance`, `maxDistance` and `eventInterval`.
|
|
273
|
+
- When an item applies a matrix it kept, through `applyMatrix = true` or
|
|
274
|
+
`item.matrix.apply()`, its strokes and dashes scale with it, so it looks the
|
|
275
|
+
same. SVG import does this too: scaled strokes keep their width from the file.
|
|
276
|
+
- `Item#replaceWith()` returns a boolean instead of the item, and
|
|
277
|
+
`Matrix#isInvertible()` a boolean instead of the determinant.
|
|
278
|
+
- A style set on a `SymbolItem` fills in what its definition's content leaves
|
|
279
|
+
unset, as SVG's `<use>` does. It had no effect before.
|
|
280
|
+
|
|
281
|
+
**SVG**
|
|
282
|
+
|
|
283
|
+
- `importSVG()` no longer loads URLs or files. Use `loadSVG()`, which returns a
|
|
284
|
+
promise: `importSVG(url, { onLoad })` becomes `await loadSVG(url)`, and
|
|
285
|
+
errors reject the promise instead of calling `onError`.
|
|
286
|
+
- `Project#importSVG()` of SVG exported by Paper.js restores its layers as the
|
|
287
|
+
project's layers, and returns them as an array instead of a group.
|
|
288
|
+
- A `<use>` keeps the styles of the element it uses, and adds its own only where
|
|
289
|
+
that element has none, as browsers do.
|
|
290
|
+
|
|
291
|
+
**Text**
|
|
292
|
+
|
|
293
|
+
Text styles take their names from CSS where it has them:
|
|
294
|
+
|
|
295
|
+
- `features` becomes `fontFeatures`, keyed by tag: `{ dlig: true, liga: false }`.
|
|
296
|
+
- `capitals` becomes `letterCase`, with `'uppercase'` and `'small-caps'`.
|
|
297
|
+
- `justifyLast` becomes `justificationLast`, with `'justify'` instead of
|
|
298
|
+
`'all'`. `justification` and `justificationLast` default to `'start'`, so
|
|
299
|
+
right-to-left paragraphs align right.
|
|
300
|
+
- `justifySpacing` becomes `justificationRanges`, with `wordSpacing`,
|
|
301
|
+
`letterSpacing` and `glyphScaling`, each as `{ min, desired, max }`.
|
|
302
|
+
- `startIndent`, `endIndent` and `firstLineIndent` become `indentStart`,
|
|
303
|
+
`indentEnd` and `indentFirstLine`, and `tabs` becomes `tabStops`.
|
|
304
|
+
- `composer` merges into `lineWrap`, which takes `'paragraph'` instead of
|
|
305
|
+
`'pretty'`.
|
|
306
|
+
- `hyphenation` is `'none'`, `'manual'` (the default: only at soft hyphens),
|
|
307
|
+
`'auto'`, or an object. Its `wordsLongerThan`, `afterFirst`, `beforeLast`,
|
|
308
|
+
`capitalized` and `limit` become `minWordLength`, `minBefore`, `minAfter`,
|
|
309
|
+
`mixedCase` and `maxLines`.
|
|
310
|
+
|
|
311
|
+
**Tweens**
|
|
312
|
+
|
|
313
|
+
- `Tween#then()` returns a promise instead of the tween, so tweens can be
|
|
314
|
+
awaited, and it calls every callback passed to it, not only the last. Call
|
|
315
|
+
`start()` on the tween, not on what `then()` returns.
|
|
316
|
+
|
|
317
|
+
**Key events**
|
|
318
|
+
|
|
319
|
+
- Characters come from `keydown` events, as `event.key` gives them, instead of
|
|
320
|
+
the deprecated `keypress`. With control or meta, keys keep their case, e.g.
|
|
321
|
+
`'A'` for control-shift-a. Dead keys and input methods give no character.
|
|
322
|
+
- The key names of Internet Explorer and the old Edge (`Spacebar`, `Del`,
|
|
323
|
+
`Win`, `Esc`) are no longer translated.
|
|
324
|
+
|
|
325
|
+
**Less common**
|
|
326
|
+
|
|
327
|
+
- Patterns no longer clip their item by its tile, whose `size` only sets how far
|
|
328
|
+
apart the item repeats. Parts beyond the tile lie over the tiles around it, the
|
|
329
|
+
left and top ones in front. To cut them off, clip the item with a rectangle of
|
|
330
|
+
the tile's size. A pattern's `spacing` is `null` unless it is set.
|
|
331
|
+
- `Item#previewBounds` includes shadows, so `rasterize()` returns larger rasters
|
|
332
|
+
for items with shadows.
|
|
333
|
+
- `Item#removeChildren(start, null)` removes up to the last child.
|
|
334
|
+
- A `null` `width` or `dashArray` in the options of `offset()`, `outline()` and
|
|
335
|
+
`dash()` falls back to the item's.
|
|
336
|
+
- `offset()` and `outline()` use a `miterLimit` of `0` as given, instead of
|
|
337
|
+
the default.
|
|
338
|
+
- Stroke profiles no longer level off at a smooth stop that lies between a
|
|
339
|
+
smaller and a larger value, so such strokes get a different outline.
|
|
340
|
+
- `Project#selectedItems` lists items in drawing order, groups before their
|
|
341
|
+
children, instead of in the order they were created.
|
|
342
|
+
|
|
343
|
+
**Projects in another app** (`paper/hosted`)
|
|
344
|
+
|
|
345
|
+
- The host's `getItem(key)` is renamed `getContent(key)`.
|
|
346
|
+
- `Project#takeChanges()` and `hasChanges()` also report items whose `data`
|
|
347
|
+
a script changed in place.
|
|
348
|
+
- Content loaded from the app takes the style the app gives it, not the
|
|
349
|
+
project's current style.
|
|
350
|
+
|
|
351
|
+
## Removed APIs
|
|
352
|
+
|
|
353
|
+
| Removed | Use instead |
|
|
354
|
+
| ----------------------------------------------------- | ------------------------------------------------------ |
|
|
355
|
+
| `Emitter#attach()`, `detach()`, `fire()` | `on()`, `off()`, `emit()` |
|
|
356
|
+
| `Item#appendTop()`, `appendBottom()` | `addChild()`, `insertChild(0, item)` |
|
|
357
|
+
| `Item#moveAbove()`, `moveBelow()` | `insertAbove()`, `insertBelow()` |
|
|
358
|
+
| `Item#transformContent` | `applyMatrix` |
|
|
359
|
+
| `Item#rasterize(resolution, insert)` | `rasterize({ resolution, insert })` |
|
|
360
|
+
| `Item#fitBounds(rectangle, true)` | `fitBounds(rectangle, 'cover')` |
|
|
361
|
+
| the `type` option of `matches()` and `hitTest()` | the `class` option |
|
|
362
|
+
| the style `leading` | `lineHeight` |
|
|
363
|
+
| the style `tracking` | `letterTracking` |
|
|
364
|
+
| the style `font` | `fontFamily` |
|
|
365
|
+
| the style `windingRule` | `fillRule` |
|
|
366
|
+
| `Project#options` | `paper.settings` |
|
|
367
|
+
| `Project#symbols` | `symbolDefinitions` |
|
|
368
|
+
| `settings.scaleStrokes` | `transform(matrix, { strokes: true })` |
|
|
369
|
+
| `Shape#shape` | `type` |
|
|
370
|
+
| `SymbolDefinition#definition` | `item` |
|
|
371
|
+
| `SymbolItem#symbol` | `definition` |
|
|
372
|
+
| `Raster#ppi` | `resolution` |
|
|
373
|
+
| `GradientStop#rampPoint` | `offset` |
|
|
374
|
+
| `PatternDefinition#tile` | `size`, which defaults to the item's bounds |
|
|
375
|
+
| `CurveLocation#parameter` | `time` |
|
|
376
|
+
| `Curve#getParameterAt()`, `getParameterOf()` | `getTimeAt()`, `getTimeOf()` |
|
|
377
|
+
| the `isTime` arguments, as in `curve.divide(t, true)` | the `…AtTime()` methods, as in `curve.divideAtTime(t)` |
|
|
378
|
+
| `Path#split(index, time)` | `splitAt(location)` |
|
|
379
|
+
| `Event#timeStamp` | `time` |
|
|
380
|
+
| `View#draw()` | `update()` |
|
|
381
|
+
| `View#scrollBy(delta)` | `translate()` with the negated delta |
|
|
382
|
+
| `PaperScope#browser` | `agent` |
|
|
383
|
+
| `paper.DomEvent`, `DomElement`, `Http` | the DOM's own APIs |
|
|
384
|
+
| the arguments of `PathItem#getPathData()` | `pathData` |
|
|
385
|
+
| the range of `Path#clear(start, end)` | `removeSegments(start, end)` |
|
|
386
|
+
| the `onExport` / `onImport` options of SVG | `processNode` / `processItem` |
|
|
387
|
+
| `TextItem#range()`, `TextStory#range()` | `getRange()` |
|
|
388
|
+
| `PaperScope.getAttribute()`, `hasAttribute()` | the `data-paper-` attributes of the element |
|
|
389
|
+
| `CurveLocation.expand()` | none |
|
|
390
|
+
| `PathItem#interiorPoint`, `getInteriorPoint()` | none |
|
|
391
|
+
| `Curve#getValues(matrix)`, `Curve.getValues()` | `curve.values` |
|
|
392
|
+
|
|
393
|
+
In place of the static methods of `Curve`:
|
|
394
|
+
|
|
395
|
+
| Removed | Use instead |
|
|
396
|
+
| ----------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
397
|
+
| `Curve.getPoint(v, t)` and its siblings | `curve.getPointAtTime(t)` and its siblings |
|
|
398
|
+
| `Curve.getPart()`, `Curve.subdivide()` | `curve.getPart(from, to)` |
|
|
399
|
+
| `Curve.getNearestTime()` | `curve.getNearestLocation(point)` |
|
|
400
|
+
| `Curve.getOverlaps()` | `curve.getIntersections(other)`, and `hasOverlap()` on its locations |
|
|
401
|
+
| `Curve.solveCubic()` | `Numerical.solveCubic()` |
|
|
402
|
+
| `Curve.getMonoCurves()`, `isFlatEnough()`, `getReversals()` | none |
|