paper 0.16.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 +294 -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 +33083 -22681
- package/dist/paper-full.min.js +36 -31
- package/dist/paper-hosted.js +33898 -23223
- 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 +90 -58
- 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 -23759
- package/dist/docs/classes/AreaText.html +0 -8708
- package/dist/docs/classes/ChangeFlag.html +0 -385
- package/dist/docs/classes/Color.html +0 -2205
- package/dist/docs/classes/CompoundPath.html +0 -9168
- package/dist/docs/classes/Curve.html +0 -2326
- package/dist/docs/classes/CurveLocation.html +0 -673
- 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 -7139
- package/dist/docs/classes/HitResult.html +0 -241
- package/dist/docs/classes/HostItem.html +0 -6836
- package/dist/docs/classes/Item.html +0 -6892
- package/dist/docs/classes/Key.html +0 -140
- package/dist/docs/classes/KeyEvent.html +0 -309
- package/dist/docs/classes/Layer.html +0 -7122
- 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 -202
- package/dist/docs/classes/Path.html +0 -12064
- package/dist/docs/classes/PathItem.html +0 -8930
- package/dist/docs/classes/PathText.html +0 -8578
- package/dist/docs/classes/Point.html +0 -2860
- package/dist/docs/classes/PointText.html +0 -8489
- package/dist/docs/classes/Project.html +0 -1604
- package/dist/docs/classes/Raster.html +0 -8069
- package/dist/docs/classes/Rectangle.html +0 -1698
- package/dist/docs/classes/Segment.html +0 -1017
- package/dist/docs/classes/Shape.html +0 -7570
- package/dist/docs/classes/Size.html +0 -1915
- package/dist/docs/classes/Style.html +0 -1765
- package/dist/docs/classes/SymbolDefinition.html +0 -312
- package/dist/docs/classes/SymbolItem.html +0 -6999
- package/dist/docs/classes/TextItem.html +0 -8332
- 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/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 -21834
- package/dist/paper-core.min.js +0 -32
- package/dist/paper.d.ts +0 -9630
- 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/MetaBalls.html +0 -132
- package/examples/Paperjs.org/NyanRainbow.html +0 -202
- 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/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/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
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
3
|
+
* http://paperjs.org/
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2011 - 2026, Jürg Lehni & Jonathan Puckey
|
|
6
|
+
* http://juerglehni.com/ & https://puckey.studio/
|
|
7
|
+
*
|
|
8
|
+
* Distributed under the MIT license. See LICENSE file for details.
|
|
9
|
+
*
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
*/
|
|
12
|
+
import { EPSILON, GEOMETRIC_EPSILON, Matrix, Point, Rectangle, isInheritingStyle } from "../internal.js";
|
|
13
|
+
// NOTE: Documentation is in Item#getBounds()
|
|
14
|
+
export function getItemBounds(item, matrix, options) {
|
|
15
|
+
const hasMatrix = options || matrix instanceof Matrix;
|
|
16
|
+
const opts = {
|
|
17
|
+
...(hasMatrix ? options : matrix),
|
|
18
|
+
...item._boundsOptions
|
|
19
|
+
};
|
|
20
|
+
// We can only cache the bounds if the path uses stroke-scaling, or if
|
|
21
|
+
// no stroke is involved in the calculation of the bounds.
|
|
22
|
+
// When strokeScaling is false, the bounds are affected by the zoom
|
|
23
|
+
// level of the view, hence we can't cache.
|
|
24
|
+
if (!opts.stroke || item.strokeScaling) {
|
|
25
|
+
opts.cacheItem = item;
|
|
26
|
+
}
|
|
27
|
+
// If we're caching bounds, pass on the item as cacheItem, so
|
|
28
|
+
// the children can setup _boundsCache structures for it.
|
|
29
|
+
return item._getCachedBounds(hasMatrix ? matrix : null, opts).rect;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Deals with the calling of _getBounds(), recursive matrix concatenation and
|
|
33
|
+
* all the caching, behind Item#_getCachedBounds(), which hosted shells
|
|
34
|
+
* override.
|
|
35
|
+
*
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
export function getCachedBounds(item, matrix, options, noInternal) {
|
|
39
|
+
// See if we can cache these bounds. We only cache the bounds
|
|
40
|
+
// transformed with the internally stored _matrix, (the default if no
|
|
41
|
+
// matrix is passed).
|
|
42
|
+
// Do not transform by the internal matrix for internal, untransformed
|
|
43
|
+
// bounds.
|
|
44
|
+
const internal = options.internal && !noInternal;
|
|
45
|
+
const { cacheItem } = options;
|
|
46
|
+
const _matrix = internal ? null : item._matrix._orNullIfIdentity();
|
|
47
|
+
// A passed identity matrix still replaces the internal matrix:
|
|
48
|
+
const transform = matrix ? matrix._orNullIfIdentity() : _matrix;
|
|
49
|
+
// Create a key for caching, reflecting all bounds options. Bounds measured
|
|
50
|
+
// through a symbol item can depend on its style, so they aren't cached,
|
|
51
|
+
// see Style#_get():
|
|
52
|
+
const cacheKey = (cacheItem &&
|
|
53
|
+
!isInheritingStyle() &&
|
|
54
|
+
(transform ? transform.equals(_matrix) : !_matrix) &&
|
|
55
|
+
getBoundsCacheKey(options, internal));
|
|
56
|
+
// Only items whose bounds come from other items need to pass the
|
|
57
|
+
// cacheItem chain on, so that clearing caches propagates up:
|
|
58
|
+
const isIntermediate = (cacheKey &&
|
|
59
|
+
cacheItem !== item &&
|
|
60
|
+
(item._children || item._definition));
|
|
61
|
+
let bounds = item._bounds;
|
|
62
|
+
// NOTE: This needs to happen before returning cached values, since even
|
|
63
|
+
// then, _boundsCache needs to be kept up-to-date.
|
|
64
|
+
updateBoundsCache(item._parent || item._symbol, cacheItem);
|
|
65
|
+
if (isIntermediate) {
|
|
66
|
+
updateBoundsCache(item, cacheItem);
|
|
67
|
+
}
|
|
68
|
+
if (cacheKey && bounds && cacheKey in bounds) {
|
|
69
|
+
const cached = bounds[cacheKey];
|
|
70
|
+
return {
|
|
71
|
+
rect: cached.rect.clone(),
|
|
72
|
+
nonscaling: cached.nonscaling
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const res = item._getBounds(transform, isIntermediate ? { ...options, cacheItem: item } : options);
|
|
76
|
+
// Support two versions of _getBounds(): One that directly returns a
|
|
77
|
+
// Rectangle, and one that returns a bounds object with nonscaling.
|
|
78
|
+
let rect = res instanceof Rectangle ? res : res.rect;
|
|
79
|
+
if (options.shadow) {
|
|
80
|
+
rect = uniteShadow(item, rect, transform);
|
|
81
|
+
}
|
|
82
|
+
const style = item._style;
|
|
83
|
+
const nonscaling = (!(res instanceof Rectangle) && res.nonscaling ||
|
|
84
|
+
style.hasStroke() && !style.strokeScaling);
|
|
85
|
+
// If we can cache the result, update the _bounds cache structure
|
|
86
|
+
// before returning
|
|
87
|
+
if (cacheKey) {
|
|
88
|
+
if (!bounds) {
|
|
89
|
+
item._bounds = bounds = {};
|
|
90
|
+
}
|
|
91
|
+
bounds[cacheKey] = {
|
|
92
|
+
rect: rect.clone(),
|
|
93
|
+
nonscaling,
|
|
94
|
+
stroke: options.stroke,
|
|
95
|
+
shadow: options.shadow,
|
|
96
|
+
// Mark as internal, so Item#transform() won't transform it
|
|
97
|
+
internal
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return { rect, nonscaling };
|
|
101
|
+
}
|
|
102
|
+
export function getBoundsCacheKey(options, internal) {
|
|
103
|
+
return [
|
|
104
|
+
options.stroke ? 1 : 0,
|
|
105
|
+
options.handle ? 1 : 0,
|
|
106
|
+
options.shadow ? 1 : 0,
|
|
107
|
+
internal ? 1 : 0
|
|
108
|
+
].join('');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns to correct matrix to use to transform stroke related geometries
|
|
112
|
+
* when calculating bounds: the item's matrix if {@link Item#strokeScaling} is
|
|
113
|
+
* `true`, otherwise the parent's inverted view matrix. The returned matrix
|
|
114
|
+
* is always shiftless, meaning its translation vector is reset to zero.
|
|
115
|
+
*
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
export function getStrokeMatrix(item, matrix, options) {
|
|
119
|
+
const parent = item.strokeScaling
|
|
120
|
+
? null
|
|
121
|
+
: options?.internal
|
|
122
|
+
? item
|
|
123
|
+
: item._parent ?? item._symbol?._item;
|
|
124
|
+
let mx = parent ? parent.viewMatrix.invert() : matrix;
|
|
125
|
+
const transform = !parent && options?.transform;
|
|
126
|
+
// When predicting the bounds after a transformation, see
|
|
127
|
+
// Item#strokeBounds, it doesn't scale the strokes of items that apply it
|
|
128
|
+
// to their content, all the way up to the transformed item:
|
|
129
|
+
if (transform) {
|
|
130
|
+
for (let owner = item; owner?._applyMatrix; owner = owner._parent) {
|
|
131
|
+
if (owner === transform.item) {
|
|
132
|
+
mx = transform.matrix.inverted()?.appended(mx) ?? null;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return mx?._shiftless() ?? null;
|
|
138
|
+
}
|
|
139
|
+
// The steps that setStrokeBounds() takes at most, and the change of the
|
|
140
|
+
// scales, relative to them, that it estimates the derivatives from:
|
|
141
|
+
const maxSolverSteps = 16;
|
|
142
|
+
const derivativeStep = 1e-6;
|
|
143
|
+
// Scales and moves the item so that its stroke bounds become the rectangle:
|
|
144
|
+
export function setStrokeBounds(item, rect) {
|
|
145
|
+
const bounds = item.getBounds();
|
|
146
|
+
const { center } = bounds;
|
|
147
|
+
// Negative sizes mirror the item, as in the bounds setter:
|
|
148
|
+
const signX = rect.width < 0 ? -1 : 1;
|
|
149
|
+
const signY = rect.height < 0 ? -1 : 1;
|
|
150
|
+
const width = Math.abs(rect.width);
|
|
151
|
+
const height = Math.abs(rect.height);
|
|
152
|
+
// Dimensions without size can't be scaled:
|
|
153
|
+
const canScaleX = !!bounds.width;
|
|
154
|
+
const canScaleY = !!bounds.height;
|
|
155
|
+
// The smallest scale that keeps the matrix invertible, for
|
|
156
|
+
// rectangles smaller than the stroke itself:
|
|
157
|
+
const min = EPSILON;
|
|
158
|
+
const epsilon = GEOMETRIC_EPSILON;
|
|
159
|
+
let sx = 1;
|
|
160
|
+
let sy = 1;
|
|
161
|
+
const getMatrix = (sx, sy) => new Matrix().scale(signX * sx, signY * sy, center);
|
|
162
|
+
// Returns the stroke bounds that the item would have when scaled by sx
|
|
163
|
+
// and sy, without transforming it. The strokes of items that apply the
|
|
164
|
+
// scaling to their content keep their width, see getStrokeMatrix():
|
|
165
|
+
const getStrokeBounds = (sx, sy) => {
|
|
166
|
+
const matrix = getMatrix(sx, sy);
|
|
167
|
+
return item.getBounds(matrix.appended(item._matrix), {
|
|
168
|
+
stroke: true,
|
|
169
|
+
transform: { matrix, item: item }
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
// Under non-uniform scaling, the extent of the stroke changes with the
|
|
173
|
+
// angles of miters, bevels and square caps, so solve for the scales
|
|
174
|
+
// with Newton's method, estimating the derivatives from small changes:
|
|
175
|
+
for (let i = 0; i < maxSolverSteps; i++) {
|
|
176
|
+
const { size } = getStrokeBounds(sx, sy);
|
|
177
|
+
const fx = canScaleX ? size.width - width : 0;
|
|
178
|
+
const fy = canScaleY ? size.height - height : 0;
|
|
179
|
+
if (Math.abs(fx) < epsilon && Math.abs(fy) < epsilon) {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
// Small changes, but large enough to be measured at tiny scales:
|
|
183
|
+
const hx = Math.max(sx, 1) * derivativeStep;
|
|
184
|
+
const hy = Math.max(sy, 1) * derivativeStep;
|
|
185
|
+
const sizeX = getStrokeBounds(sx + hx, sy).size;
|
|
186
|
+
const sizeY = getStrokeBounds(sx, sy + hy).size;
|
|
187
|
+
const a = canScaleX ? (sizeX.width - size.width) / hx : 1;
|
|
188
|
+
const b = canScaleX && canScaleY ? (sizeY.width - size.width) / hy : 0;
|
|
189
|
+
const c = canScaleX && canScaleY ? (sizeX.height - size.height) / hx : 0;
|
|
190
|
+
const d = canScaleY ? (sizeY.height - size.height) / hy : 1;
|
|
191
|
+
const det = a * d - b * c;
|
|
192
|
+
if (!det) {
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
const nx = Math.max(sx - (fx * d - fy * b) / det, min);
|
|
196
|
+
const ny = Math.max(sy - (fy * a - fx * c) / det, min);
|
|
197
|
+
// Stop where rectangles smaller than the stroke keep the scales at
|
|
198
|
+
// their minimum:
|
|
199
|
+
if (nx === sx && ny === sy) {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
sx = nx;
|
|
203
|
+
sy = ny;
|
|
204
|
+
}
|
|
205
|
+
// Scale the item, and move the center of its stroke bounds to the
|
|
206
|
+
// rectangle's center, which centers what can't be reached:
|
|
207
|
+
item.transform(new Matrix()
|
|
208
|
+
.translate(rect.center.subtract(getStrokeBounds(sx, sy).center))
|
|
209
|
+
.append(getMatrix(sx, sy)));
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Set up a boundsCache structure that keeps track of items that keep
|
|
213
|
+
* cached bounds that depend on an item. We store this in the parent,
|
|
214
|
+
* for multiple reasons:
|
|
215
|
+
* The parent receives CHILDREN change notifications for when its
|
|
216
|
+
* children are added or removed and can thus clear the cache, and we
|
|
217
|
+
* save a lot of memory, e.g. when grouping 100 items and asking the
|
|
218
|
+
* group for its bounds. If stored on the children, we would have 100
|
|
219
|
+
* times the same structure.
|
|
220
|
+
*
|
|
221
|
+
* @private
|
|
222
|
+
*/
|
|
223
|
+
export function updateBoundsCache(parent, item) {
|
|
224
|
+
if (parent && item) {
|
|
225
|
+
// Set-up the parent's boundsCache structure if it does not
|
|
226
|
+
// exist yet and add the item to it.
|
|
227
|
+
const { id } = item;
|
|
228
|
+
const ref = (parent._boundsCache ??= {
|
|
229
|
+
// Use a hash-table for ids and an array for the list,
|
|
230
|
+
// so we can keep track of items that were added already
|
|
231
|
+
ids: {},
|
|
232
|
+
list: []
|
|
233
|
+
});
|
|
234
|
+
if (!ref.ids[id]) {
|
|
235
|
+
ref.list.push(item);
|
|
236
|
+
ref.ids[id] = item;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Clears cached bounds of all items that the children of the item are
|
|
242
|
+
* contributing to. See updateBoundsCache() for an explanation why this
|
|
243
|
+
* information is stored on parents, not the children themselves.
|
|
244
|
+
*
|
|
245
|
+
* @private
|
|
246
|
+
*/
|
|
247
|
+
export function clearBoundsCache(item) {
|
|
248
|
+
// Clear the position as well, since it's depending on bounds.
|
|
249
|
+
const cache = item._boundsCache;
|
|
250
|
+
if (cache) {
|
|
251
|
+
// Erase cache before looping, to prevent circular recursion.
|
|
252
|
+
item._bounds = item._position = item._boundsCache = undefined;
|
|
253
|
+
for (const other of cache.list) {
|
|
254
|
+
if (other !== item) {
|
|
255
|
+
other._bounds = other._position = undefined;
|
|
256
|
+
// We need to recursively call clearBoundsCache(), as
|
|
257
|
+
// when the cache for the other item's children is not
|
|
258
|
+
// valid anymore, that propagates up the scene graph.
|
|
259
|
+
if (other._boundsCache) {
|
|
260
|
+
clearBoundsCache(other);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Gets the combined bounds of all specified items, transformed by the
|
|
268
|
+
* matrix, or in project coordinates if global is set.
|
|
269
|
+
*
|
|
270
|
+
* @private
|
|
271
|
+
*/
|
|
272
|
+
export function getCombinedBounds(items, matrix, options, global) {
|
|
273
|
+
let x1 = Infinity;
|
|
274
|
+
let x2 = -x1;
|
|
275
|
+
let y1 = x1;
|
|
276
|
+
let y2 = x2;
|
|
277
|
+
let nonscaling = false;
|
|
278
|
+
// NOTE: As soon as one child-item has non-scaling strokes, the full
|
|
279
|
+
// bounds need to be considered non-scaling for caching purposes.
|
|
280
|
+
const opts = options ?? {};
|
|
281
|
+
for (const item of items) {
|
|
282
|
+
// Item is handled if it is visible and not recursively empty.
|
|
283
|
+
// This avoid errors with nested empty groups (#1467).
|
|
284
|
+
if (item._visible && !item.isEmpty(true)) {
|
|
285
|
+
// Pass true for noInternal, since even when getting
|
|
286
|
+
// internal bounds for this item, we need to apply the
|
|
287
|
+
// matrices to its children.
|
|
288
|
+
const bounds = item._getCachedBounds(global
|
|
289
|
+
? item._getGlobalMatrix(true)
|
|
290
|
+
: (matrix?.appended(item._matrix) ?? null), opts, true);
|
|
291
|
+
const { rect } = bounds;
|
|
292
|
+
x1 = Math.min(rect.x, x1);
|
|
293
|
+
y1 = Math.min(rect.y, y1);
|
|
294
|
+
x2 = Math.max(rect.x + rect.width, x2);
|
|
295
|
+
y2 = Math.max(rect.y + rect.height, y2);
|
|
296
|
+
if (bounds.nonscaling) {
|
|
297
|
+
nonscaling = true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return {
|
|
302
|
+
rect: isFinite(x1)
|
|
303
|
+
? new Rectangle(x1, y1, x2 - x1, y2 - y1)
|
|
304
|
+
: new Rectangle(),
|
|
305
|
+
nonscaling
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
// Unites the bounds with the item's own shadow, which canvas casts in the
|
|
309
|
+
// item's coordinates, and blurs up to three standard deviations of half its
|
|
310
|
+
// shadowBlur each, see setShadow() in draw.ts:
|
|
311
|
+
function uniteShadow(item, rect, matrix) {
|
|
312
|
+
const style = item._style;
|
|
313
|
+
if (item._castsShadow &&
|
|
314
|
+
style._get('shadowColor', true) &&
|
|
315
|
+
!item.isEmpty()) {
|
|
316
|
+
const mx = matrix?._shiftless() ?? new Matrix();
|
|
317
|
+
const offset = mx.transform(style._get('shadowOffset', true));
|
|
318
|
+
const blur = mx.transform(new Point(style._get('shadowBlur', true), 0));
|
|
319
|
+
return rect.unite(new Rectangle(rect.point.add(offset), rect.size).expand(blur.length * 3));
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
return rect;
|
|
323
|
+
}
|
|
324
|
+
}
|