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,1190 @@
|
|
|
1
|
+
import { CompoundPath, Curve, Group, Item, Path, Point } from '../internal.ts';
|
|
2
|
+
import type { PointLike } from '../basic/Point.ts';
|
|
3
|
+
import type { SizeLike } from '../basic/Size.ts';
|
|
4
|
+
import type { Matrix } from '../basic/Matrix.ts';
|
|
5
|
+
import type { CurveLocation } from './CurveLocation.ts';
|
|
6
|
+
import type { SegmentLike } from './Segment.ts';
|
|
7
|
+
import type { BooleanOptions } from './boolean.ts';
|
|
8
|
+
import type { Graph } from '../boolean/graph.ts';
|
|
9
|
+
import type { FillRule } from '../values/region.ts';
|
|
10
|
+
import type { PathOffsetOptions, PathOutlineOptions } from './offset.ts';
|
|
11
|
+
import type { PathSimplifyOptions, PathSmoothOptions } from './smooth.ts';
|
|
12
|
+
import type { ItemProps } from '../item/props.ts';
|
|
13
|
+
export type DashOptions = {
|
|
14
|
+
dashArray?: number[];
|
|
15
|
+
dashOffset?: number;
|
|
16
|
+
insert?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type CubicCoordinates = [
|
|
19
|
+
x1: number,
|
|
20
|
+
y1: number,
|
|
21
|
+
x2: number,
|
|
22
|
+
y2: number,
|
|
23
|
+
x: number,
|
|
24
|
+
y: number
|
|
25
|
+
];
|
|
26
|
+
export type QuadraticCoordinates = [
|
|
27
|
+
x1: number,
|
|
28
|
+
y1: number,
|
|
29
|
+
x: number,
|
|
30
|
+
y: number
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* The PathItem class is the base for any items that describe paths and
|
|
34
|
+
* offer standardised methods for drawing and path manipulation, such as
|
|
35
|
+
* {@link Path} and {@link CompoundPath}.
|
|
36
|
+
*/
|
|
37
|
+
export declare abstract class PathItem extends Item {
|
|
38
|
+
_scaleStroke(matrix: Matrix): void;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a path item from the given SVG path-data, determining if the
|
|
41
|
+
* data describes a plain path or a compound-path with multiple
|
|
42
|
+
* sub-paths.
|
|
43
|
+
*
|
|
44
|
+
* @param pathData the SVG path-data to parse
|
|
45
|
+
* @return the newly created path item
|
|
46
|
+
*/
|
|
47
|
+
static create(pathData: string): Path | CompoundPath;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a path item from the given segments array, determining if the
|
|
50
|
+
* array describes a plain path or a compound-path with multiple
|
|
51
|
+
* sub-paths.
|
|
52
|
+
*
|
|
53
|
+
* `Path.create()` and `CompoundPath.create()` are the same function: use
|
|
54
|
+
* `Path.create()` as the factory form of `new Path()`, next to the
|
|
55
|
+
* factories for shapes such as {@link Path.circle(center, radius)}.
|
|
56
|
+
*
|
|
57
|
+
* @param segments the segments array to parse
|
|
58
|
+
* @return the newly created path item
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* var path = Path.create([[20, 20], [80, 80], [140, 20]]);
|
|
62
|
+
* path.strokeColor = 'black';
|
|
63
|
+
*/
|
|
64
|
+
static create(segments: SegmentLike[] | SegmentLike[][]): Path | CompoundPath;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a path item from the given object, determining if the
|
|
67
|
+
* contained information describes a plain path or a compound-path with
|
|
68
|
+
* multiple sub-paths.
|
|
69
|
+
*
|
|
70
|
+
* @param object an object containing the properties describing
|
|
71
|
+
* the item to be created
|
|
72
|
+
* @return the newly created path item
|
|
73
|
+
*/
|
|
74
|
+
static create(object: ItemProps<Path> | ItemProps<CompoundPath>): Path | CompoundPath;
|
|
75
|
+
_asPathItem(): PathItem;
|
|
76
|
+
/**
|
|
77
|
+
* Specifies whether the path as a whole is oriented clock-wise, by looking
|
|
78
|
+
* at the path's area.
|
|
79
|
+
* Note that self-intersecting paths and sub-paths of different orientation
|
|
80
|
+
* can result in areas that cancel each other out.
|
|
81
|
+
*
|
|
82
|
+
* @see Path#area
|
|
83
|
+
* @see CompoundPath#area
|
|
84
|
+
*/
|
|
85
|
+
get clockwise(): boolean;
|
|
86
|
+
set clockwise(clockwise: boolean);
|
|
87
|
+
/**
|
|
88
|
+
* The path's geometry, formatted as SVG style path data.
|
|
89
|
+
*/
|
|
90
|
+
get pathData(): string;
|
|
91
|
+
set pathData(data: string);
|
|
92
|
+
abstract _hasStrokeProfile(): boolean;
|
|
93
|
+
abstract _getStrokeOutline(): PathItem;
|
|
94
|
+
_hasEffects(): boolean;
|
|
95
|
+
_applyEffects(art: Item): Item | null;
|
|
96
|
+
_canComposite(): boolean;
|
|
97
|
+
_contains(point: Point): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* {@grouptitle Path Intersections and Locations}
|
|
100
|
+
*
|
|
101
|
+
* Returns all intersections between two {@link PathItem} items as an array
|
|
102
|
+
* of {@link CurveLocation} objects. {@link CompoundPath} items are also
|
|
103
|
+
* supported.
|
|
104
|
+
*
|
|
105
|
+
* @param path the other item to find the intersections with
|
|
106
|
+
* @param include a callback function that can be used to
|
|
107
|
+
* filter out undesired locations right while they are collected. When
|
|
108
|
+
* defined, it shall return {@true to include a location}.
|
|
109
|
+
* @return the locations of all intersection between the
|
|
110
|
+
* paths
|
|
111
|
+
* @see #getCrossings(path)
|
|
112
|
+
* @example {@paperscript} // Finding the intersections between two paths
|
|
113
|
+
* var path = Path.rectangle(new Point(30, 25), new Size(50, 50));
|
|
114
|
+
* path.strokeColor = 'black';
|
|
115
|
+
*
|
|
116
|
+
* var secondPath = path.clone();
|
|
117
|
+
* var intersectionGroup = new Group();
|
|
118
|
+
*
|
|
119
|
+
* function onFrame(event) {
|
|
120
|
+
* secondPath.rotate(1);
|
|
121
|
+
*
|
|
122
|
+
* var intersections = path.getIntersections(secondPath);
|
|
123
|
+
* intersectionGroup.removeChildren();
|
|
124
|
+
*
|
|
125
|
+
* for (var i = 0; i < intersections.length; i++) {
|
|
126
|
+
* var intersectionPath = Path.circle({
|
|
127
|
+
* center: intersections[i].point,
|
|
128
|
+
* radius: 4,
|
|
129
|
+
* fillColor: 'red',
|
|
130
|
+
* parent: intersectionGroup
|
|
131
|
+
* });
|
|
132
|
+
* }
|
|
133
|
+
* }
|
|
134
|
+
*/
|
|
135
|
+
getIntersections(path?: PathItem, include?: ((location: CurveLocation) => boolean) | null, _matrix?: Matrix | null, _returnFirst?: boolean): CurveLocation[];
|
|
136
|
+
/**
|
|
137
|
+
* Returns all crossings between two {@link PathItem} items as an array of
|
|
138
|
+
* {@link CurveLocation} objects. {@link CompoundPath} items are also
|
|
139
|
+
* supported. Crossings are intersections where the paths actually are
|
|
140
|
+
* crossing each other, as opposed to simply touching.
|
|
141
|
+
*
|
|
142
|
+
* @param path the other item to find the crossings with
|
|
143
|
+
* @return the locations of all crossings between the
|
|
144
|
+
* paths
|
|
145
|
+
* @see #getIntersections(path)
|
|
146
|
+
*/
|
|
147
|
+
getCrossings(path: PathItem): CurveLocation[];
|
|
148
|
+
/**
|
|
149
|
+
* Returns the nearest location on the path item to the specified point.
|
|
150
|
+
*
|
|
151
|
+
* @param point the point for which we search the nearest location
|
|
152
|
+
* @return the location on the path that's the closest to
|
|
153
|
+
* the specified point
|
|
154
|
+
*/
|
|
155
|
+
getNearestLocation(point: PointLike | number, y?: number): CurveLocation | null;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the nearest point on the path item to the specified point.
|
|
158
|
+
*
|
|
159
|
+
* @param point the point for which we search the nearest point
|
|
160
|
+
* @return the point on the path that's the closest to the specified
|
|
161
|
+
* point
|
|
162
|
+
*
|
|
163
|
+
* @example {@paperscript height=200}
|
|
164
|
+
* var star = Path.star({
|
|
165
|
+
* center: view.center,
|
|
166
|
+
* points: 10,
|
|
167
|
+
* radius1: 30,
|
|
168
|
+
* radius2: 60,
|
|
169
|
+
* strokeColor: 'black'
|
|
170
|
+
* });
|
|
171
|
+
*
|
|
172
|
+
* var circle = Path.circle({
|
|
173
|
+
* center: view.center,
|
|
174
|
+
* radius: 3,
|
|
175
|
+
* fillColor: 'red'
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* function onMouseMove(event) {
|
|
179
|
+
* // Get the nearest point from the mouse position
|
|
180
|
+
* // to the star shaped path:
|
|
181
|
+
* var nearestPoint = star.getNearestPoint(event.point);
|
|
182
|
+
*
|
|
183
|
+
* // Move the red circle to the nearest point:
|
|
184
|
+
* circle.position = nearestPoint;
|
|
185
|
+
* }
|
|
186
|
+
*/
|
|
187
|
+
getNearestPoint(point: PointLike | number, y?: number): Point | null;
|
|
188
|
+
/**
|
|
189
|
+
* {@grouptitle Path Manipulation}
|
|
190
|
+
*
|
|
191
|
+
* Reverses the orientation of the path item. When called on
|
|
192
|
+
* {@link CompoundPath} items, each of the nested paths is reversed. On
|
|
193
|
+
* {@link Path} items, the sequence of {@link Path#segments} is reversed.
|
|
194
|
+
*
|
|
195
|
+
* @return this path itself, so calls can be chained
|
|
196
|
+
* @chainable
|
|
197
|
+
*/
|
|
198
|
+
abstract reverse(): this;
|
|
199
|
+
/**
|
|
200
|
+
* Flattens the curves in path items to a sequence of straight lines, by
|
|
201
|
+
* subdividing them enough times until the specified maximum error is met.
|
|
202
|
+
*
|
|
203
|
+
* @param flatness the maximum error between the flattened
|
|
204
|
+
* lines and the original curves
|
|
205
|
+
* @return this path itself, so calls can be chained
|
|
206
|
+
* @chainable
|
|
207
|
+
*
|
|
208
|
+
* @example {@paperscript}
|
|
209
|
+
* // Flattening a circle shaped path:
|
|
210
|
+
*
|
|
211
|
+
* // Create a circle shaped path at { x: 80, y: 50 }
|
|
212
|
+
* // with a radius of 35:
|
|
213
|
+
* var path = Path.circle({
|
|
214
|
+
* center: [80, 50],
|
|
215
|
+
* radius: 35
|
|
216
|
+
* });
|
|
217
|
+
*
|
|
218
|
+
* // Select the path, so we can inspect its segments:
|
|
219
|
+
* path.selected = true;
|
|
220
|
+
*
|
|
221
|
+
* // Create a copy of the path and move it by 150 points:
|
|
222
|
+
* var copy = path.clone();
|
|
223
|
+
* copy.position.x += 150;
|
|
224
|
+
*
|
|
225
|
+
* // Flatten the copied path, with a maximum error of 4 points:
|
|
226
|
+
* copy.flatten(4);
|
|
227
|
+
*/
|
|
228
|
+
abstract flatten(flatness?: number): this;
|
|
229
|
+
/**
|
|
230
|
+
* Smooths the path item without changing the amount of segments in the path
|
|
231
|
+
* or moving the segments' locations, by smoothing and adjusting the angle
|
|
232
|
+
* and length of the segments' handles based on the position and distance of
|
|
233
|
+
* neighboring segments.
|
|
234
|
+
*
|
|
235
|
+
* Smoothing works both for open paths and closed paths, and can be applied
|
|
236
|
+
* to the full path, as well as a sub-range of it. If a range is defined
|
|
237
|
+
* using the `options.from` and `options.to` properties, only the curve
|
|
238
|
+
* handles inside that range are touched. If one or both limits of the range
|
|
239
|
+
* are specified in negative indices, the indices are wrapped around the end
|
|
240
|
+
* of the curve. That way, a smoothing range in a close path can even wrap
|
|
241
|
+
* around the connection between the last and the first segment.
|
|
242
|
+
*
|
|
243
|
+
* Four different smoothing methods are available:
|
|
244
|
+
*
|
|
245
|
+
* - `'continuous'` smooths the path item by adjusting its curve handles so
|
|
246
|
+
* that the first and second derivatives of all involved curves are
|
|
247
|
+
* continuous across their boundaries.
|
|
248
|
+
*
|
|
249
|
+
* This method tends to result in the smoothest results, but does not
|
|
250
|
+
* allow for further parametrization of the handles.
|
|
251
|
+
*
|
|
252
|
+
* - `'asymmetric'` is based on the same principle as `'continuous'` but
|
|
253
|
+
* uses different factors so that the result is asymmetric. This used to
|
|
254
|
+
* the only method available until v0.10.0, and is currently still the
|
|
255
|
+
* default when no method is specified, for reasons of backward
|
|
256
|
+
* compatibility. It will eventually be removed.
|
|
257
|
+
*
|
|
258
|
+
* - `'catmull-rom'` uses the Catmull-Rom spline to smooth the segment.
|
|
259
|
+
*
|
|
260
|
+
* The optionally passed factor controls the knot parametrization of the
|
|
261
|
+
* algorithm:
|
|
262
|
+
*
|
|
263
|
+
* - `0.0`: the standard, uniform Catmull-Rom spline
|
|
264
|
+
* - `0.5`: the centripetal Catmull-Rom spline, guaranteeing no
|
|
265
|
+
* self-intersections
|
|
266
|
+
* - `1.0`: the chordal Catmull-Rom spline
|
|
267
|
+
*
|
|
268
|
+
* - `'geometric'` use a simple heuristic and empiric geometric method to
|
|
269
|
+
* smooth the segment's handles. The handles were weighted, meaning that
|
|
270
|
+
* big differences in distances between the segments will lead to
|
|
271
|
+
* probably undesired results.
|
|
272
|
+
*
|
|
273
|
+
* The optionally passed factor defines the tension parameter (`0...1`),
|
|
274
|
+
* controlling the amount of smoothing as a factor by which to scale
|
|
275
|
+
* each handle.
|
|
276
|
+
*
|
|
277
|
+
* @option [options.type='asymmetric'] {String} the type of smoothing
|
|
278
|
+
* method: {@values 'continuous', 'asymmetric', 'catmull-rom',
|
|
279
|
+
* 'geometric'}
|
|
280
|
+
* @option options.factor {Number} the factor parameterizing the smoothing
|
|
281
|
+
* method — default: `0.5` for `'catmull-rom'`, `0.4` for `'geometric'`
|
|
282
|
+
* @option options.from {Number|Segment|Curve} the segment or curve at which
|
|
283
|
+
* to start smoothing, if not the full path shall be smoothed
|
|
284
|
+
* (inclusive). This can either be a segment index, or a segment or
|
|
285
|
+
* curve object that is part of the path. If the passed number is
|
|
286
|
+
* negative, the index is wrapped around the end of the path.
|
|
287
|
+
* @option options.to {Number|Segment|Curve} the segment or curve to which
|
|
288
|
+
* the handles of the path shall be processed (inclusive). This can
|
|
289
|
+
* either be a segment index, or a segment or curve object that is part
|
|
290
|
+
* of the path. If the passed number is negative, the index is wrapped
|
|
291
|
+
* around the end of the path.
|
|
292
|
+
*
|
|
293
|
+
* @param options the smoothing options
|
|
294
|
+
* @see Segment#smooth([options])
|
|
295
|
+
* @return this path itself, so calls can be chained
|
|
296
|
+
* @chainable
|
|
297
|
+
*
|
|
298
|
+
* @example {@paperscript}
|
|
299
|
+
* // Smoothing a closed shape:
|
|
300
|
+
*
|
|
301
|
+
* // Create a rectangular path with its top-left point at
|
|
302
|
+
* // {x: 30, y: 25} and a size of {width: 50, height: 50}:
|
|
303
|
+
* var path = Path.rectangle({
|
|
304
|
+
* point: [30, 25],
|
|
305
|
+
* size: [50, 50],
|
|
306
|
+
* strokeColor: 'black',
|
|
307
|
+
* });
|
|
308
|
+
*
|
|
309
|
+
* // Select the path, so we can see its handles:
|
|
310
|
+
* path.fullySelected = true;
|
|
311
|
+
*
|
|
312
|
+
* // Create a copy of the path and move it 100 to the right:
|
|
313
|
+
* var copy = path.clone();
|
|
314
|
+
* copy.position.x += 100;
|
|
315
|
+
*
|
|
316
|
+
* // Smooth the segments of the copy:
|
|
317
|
+
* copy.smooth({ type: 'continuous' });
|
|
318
|
+
*
|
|
319
|
+
* @example {@paperscript height=220}
|
|
320
|
+
* var path = new Path();
|
|
321
|
+
* path.strokeColor = 'black';
|
|
322
|
+
*
|
|
323
|
+
* path.add(new Point(30, 50));
|
|
324
|
+
*
|
|
325
|
+
* var y = 5;
|
|
326
|
+
* var x = 3;
|
|
327
|
+
*
|
|
328
|
+
* for (var i = 0; i < 28; i++) {
|
|
329
|
+
* y *= -1.1;
|
|
330
|
+
* x *= 1.1;
|
|
331
|
+
* path.lineBy(x, y);
|
|
332
|
+
* }
|
|
333
|
+
*
|
|
334
|
+
* // Create a copy of the path and move it 100 down:
|
|
335
|
+
* var copy = path.clone();
|
|
336
|
+
* copy.position.y += 120;
|
|
337
|
+
*
|
|
338
|
+
* // Select the path, so we can see its handles:
|
|
339
|
+
* copy.fullySelected = true;
|
|
340
|
+
*
|
|
341
|
+
* // Smooth the path using centripetal Catmull-Rom splines:
|
|
342
|
+
* copy.smooth({ type: 'catmull-rom', factor: 0.5 });
|
|
343
|
+
*
|
|
344
|
+
* @example {@paperscript height=110}
|
|
345
|
+
* // Smoothing ranges of paths, using segments, curves or indices:
|
|
346
|
+
*
|
|
347
|
+
* // Create 5 rectangles, next to each other:
|
|
348
|
+
* var paths = [];
|
|
349
|
+
* for (var i = 0; i < 5; i++) {
|
|
350
|
+
* paths.push(Path.rectangle({
|
|
351
|
+
* point: [30 + i * 100, 30],
|
|
352
|
+
* size: [50, 50],
|
|
353
|
+
* fullySelected: true
|
|
354
|
+
* }));
|
|
355
|
+
* }
|
|
356
|
+
* // Smooth a range, using segments:
|
|
357
|
+
* paths[1].smooth({
|
|
358
|
+
* type: 'continuous',
|
|
359
|
+
* from: paths[1].segments[0],
|
|
360
|
+
* to: paths[1].segments[2]
|
|
361
|
+
* });
|
|
362
|
+
*
|
|
363
|
+
* // Smooth a range, using curves:
|
|
364
|
+
* paths[2].smooth({
|
|
365
|
+
* type: 'continuous',
|
|
366
|
+
* from: paths[2].curves[0],
|
|
367
|
+
* to: paths[2].curves[1]
|
|
368
|
+
* });
|
|
369
|
+
*
|
|
370
|
+
* // Smooth a range, using indices:
|
|
371
|
+
* paths[3].smooth({ type: 'continuous', from: 0, to: 2 });
|
|
372
|
+
*
|
|
373
|
+
* // Smooth a range, using negative indices:
|
|
374
|
+
* paths[4].smooth({ type: 'continuous', from: -1, to: 1 });
|
|
375
|
+
*/
|
|
376
|
+
abstract smooth(options?: PathSmoothOptions): this;
|
|
377
|
+
/**
|
|
378
|
+
* Fits a sequence of as few curves as possible through the path's anchor
|
|
379
|
+
* points, ignoring the path item's curve-handles, with an allowed maximum
|
|
380
|
+
* error. When called on {@link CompoundPath} items, each of the nested
|
|
381
|
+
* paths is simplified. On {@link Path} items, the {@link Path#segments}
|
|
382
|
+
* array is processed and replaced by the resulting sequence of fitted
|
|
383
|
+
* curves.
|
|
384
|
+
*
|
|
385
|
+
* This method can be used to process and simplify the point data received
|
|
386
|
+
* from a mouse or touch device.
|
|
387
|
+
*
|
|
388
|
+
* With `options.from` and `options.to`, only the segments in that range
|
|
389
|
+
* are replaced. The fitted curves join the curves outside of the range
|
|
390
|
+
* tangentially where these have handles.
|
|
391
|
+
*
|
|
392
|
+
* @option [options.tolerance=2.5] {Number} the allowed maximum error when
|
|
393
|
+
* fitting the curves through the segment points
|
|
394
|
+
* @option options.from {Number|Segment|Curve} the segment or curve at which
|
|
395
|
+
* to start simplifying, if not the full path shall be simplified
|
|
396
|
+
* (inclusive). This can either be a segment index, or a segment or
|
|
397
|
+
* curve object that is part of the path. If the passed number is
|
|
398
|
+
* negative, the index is wrapped around the end of the path.
|
|
399
|
+
* @option options.to {Number|Segment|Curve} the segment or curve up to
|
|
400
|
+
* which to simplify (inclusive). This can either be a segment index,
|
|
401
|
+
* or a segment or curve object that is part of the path. If the passed
|
|
402
|
+
* number is negative, the index is wrapped around the end of the path.
|
|
403
|
+
*
|
|
404
|
+
* @param options the simplification options, or the
|
|
405
|
+
* tolerance as a number
|
|
406
|
+
* @return {@true if the method was capable of fitting curves
|
|
407
|
+
* through the path's segment points}
|
|
408
|
+
*
|
|
409
|
+
* @example {@paperscript height=300}
|
|
410
|
+
* // Click and drag below to draw a line. When you release the mouse,
|
|
411
|
+
* // the path is made smooth using path.simplify():
|
|
412
|
+
*
|
|
413
|
+
* var path;
|
|
414
|
+
* function onMouseDown(event) {
|
|
415
|
+
* // If we already made a path before, deselect it:
|
|
416
|
+
* if (path) {
|
|
417
|
+
* path.selected = false;
|
|
418
|
+
* }
|
|
419
|
+
*
|
|
420
|
+
* // Create a new path and add the position of the mouse
|
|
421
|
+
* // as its first segment. Select it, so we can see the
|
|
422
|
+
* // segment points:
|
|
423
|
+
* path = new Path({
|
|
424
|
+
* segments: [event.point],
|
|
425
|
+
* strokeColor: 'black',
|
|
426
|
+
* selected: true
|
|
427
|
+
* });
|
|
428
|
+
* }
|
|
429
|
+
*
|
|
430
|
+
* function onMouseDrag(event) {
|
|
431
|
+
* // On every drag event, add a segment to the path
|
|
432
|
+
* // at the position of the mouse:
|
|
433
|
+
* path.add(event.point);
|
|
434
|
+
* }
|
|
435
|
+
*
|
|
436
|
+
* function onMouseUp(event) {
|
|
437
|
+
* // When the mouse is released, simplify the path:
|
|
438
|
+
* path.simplify();
|
|
439
|
+
* path.selected = true;
|
|
440
|
+
* }
|
|
441
|
+
*/
|
|
442
|
+
abstract simplify(options?: PathSimplifyOptions | number): boolean;
|
|
443
|
+
/**
|
|
444
|
+
* Interpolates between the two specified path items and uses the result
|
|
445
|
+
* as the geometry for this path item. The number of children and
|
|
446
|
+
* segments in the two paths involved in the operation should be the same.
|
|
447
|
+
* The stroke profiles of the paths are blended too, see
|
|
448
|
+
* {@link Path#strokeProfile}.
|
|
449
|
+
*
|
|
450
|
+
* @param from the path item defining the geometry when `factor`
|
|
451
|
+
* is `0`
|
|
452
|
+
* @param to the path item defining the geometry when `factor`
|
|
453
|
+
* is `1`
|
|
454
|
+
* @param factor the interpolation coefficient, typically between
|
|
455
|
+
* `0` and `1`, but extrapolation is possible too
|
|
456
|
+
*/
|
|
457
|
+
interpolate(from: PathItem, to: PathItem, factor: number): void;
|
|
458
|
+
/**
|
|
459
|
+
* Compares the geometry of two paths to see if they describe the same
|
|
460
|
+
* shape, detecting cases where paths start in different segments or even
|
|
461
|
+
* use different amounts of curves to describe the same shape, as long as
|
|
462
|
+
* their orientation is the same, and their segments and handles really
|
|
463
|
+
* result in the same visual appearance of curves.
|
|
464
|
+
*
|
|
465
|
+
* @param path the path to compare this path's geometry with
|
|
466
|
+
* @return {@true if two paths describe the same shape}
|
|
467
|
+
*/
|
|
468
|
+
compare(path: PathItem): boolean;
|
|
469
|
+
/**
|
|
470
|
+
* {@grouptitle Postscript Style Drawing Commands}
|
|
471
|
+
*
|
|
472
|
+
* On a normal empty {@link Path}, the point is simply added as the path's
|
|
473
|
+
* first segment. If called on a {@link CompoundPath}, a new {@link Path} is
|
|
474
|
+
* created as a child and the point is added as its first segment.
|
|
475
|
+
*
|
|
476
|
+
* @param point the point in which to start the path
|
|
477
|
+
* @return this path itself, so calls can be chained
|
|
478
|
+
* @chainable
|
|
479
|
+
*/
|
|
480
|
+
abstract moveTo(point: PointLike | number, y?: number): this;
|
|
481
|
+
/**
|
|
482
|
+
* Adds a straight curve to the path, from the last segment in the path
|
|
483
|
+
* to the specified point.
|
|
484
|
+
*
|
|
485
|
+
* @param point the destination point of the newly added straight
|
|
486
|
+
* curve
|
|
487
|
+
* @return this path itself, so calls can be chained
|
|
488
|
+
* @chainable
|
|
489
|
+
*/
|
|
490
|
+
abstract lineTo(point: PointLike | number, y?: number): this;
|
|
491
|
+
/**
|
|
492
|
+
* Adds an arc from the position of the last segment in the path, passing
|
|
493
|
+
* through the specified `through` point, to the specified `to` point, by
|
|
494
|
+
* adding one or more segments to the path.
|
|
495
|
+
*
|
|
496
|
+
* @param through the point where the arc should pass through
|
|
497
|
+
* @param to the point where the arc should end
|
|
498
|
+
* @return this path itself, so calls can be chained
|
|
499
|
+
* @chainable
|
|
500
|
+
*
|
|
501
|
+
* @example {@paperscript}
|
|
502
|
+
* var path = new Path();
|
|
503
|
+
* path.strokeColor = 'black';
|
|
504
|
+
*
|
|
505
|
+
* var firstPoint = new Point(30, 75);
|
|
506
|
+
* path.add(firstPoint);
|
|
507
|
+
*
|
|
508
|
+
* // The point through which we will create the arc:
|
|
509
|
+
* var throughPoint = new Point(40, 40);
|
|
510
|
+
*
|
|
511
|
+
* // The point at which the arc will end:
|
|
512
|
+
* var toPoint = new Point(130, 75);
|
|
513
|
+
*
|
|
514
|
+
* // Draw an arc through 'throughPoint' to 'toPoint'
|
|
515
|
+
* path.arcTo(throughPoint, toPoint);
|
|
516
|
+
*
|
|
517
|
+
* // Add a red circle shaped path at the position of 'throughPoint':
|
|
518
|
+
* var circle = Path.circle(throughPoint, 3);
|
|
519
|
+
* circle.fillColor = 'red';
|
|
520
|
+
*
|
|
521
|
+
* @example {@paperscript height=300}
|
|
522
|
+
* // Interactive example. Click and drag in the view below:
|
|
523
|
+
*
|
|
524
|
+
* var myPath;
|
|
525
|
+
* function onMouseDrag(event) {
|
|
526
|
+
* // If we created a path before, remove it:
|
|
527
|
+
* if (myPath) {
|
|
528
|
+
* myPath.remove();
|
|
529
|
+
* }
|
|
530
|
+
*
|
|
531
|
+
* // Create a new path and add a segment point to it
|
|
532
|
+
* // at {x: 150, y: 150):
|
|
533
|
+
* myPath = new Path();
|
|
534
|
+
* myPath.add(new Point(150, 150));
|
|
535
|
+
*
|
|
536
|
+
* // Draw an arc through the position of the mouse to 'toPoint'
|
|
537
|
+
* var toPoint = new Point(350, 150);
|
|
538
|
+
* myPath.arcTo(event.point, toPoint);
|
|
539
|
+
*
|
|
540
|
+
* // Select the path, so we can see its segments:
|
|
541
|
+
* myPath.selected = true;
|
|
542
|
+
* }
|
|
543
|
+
*
|
|
544
|
+
* // When the mouse is released, deselect the path
|
|
545
|
+
* // and fill it with black.
|
|
546
|
+
* function onMouseUp(event) {
|
|
547
|
+
* myPath.selected = false;
|
|
548
|
+
* myPath.fillColor = 'black';
|
|
549
|
+
* }
|
|
550
|
+
*/
|
|
551
|
+
abstract arcTo(through: PointLike, to: PointLike): this;
|
|
552
|
+
/**
|
|
553
|
+
* Adds an arc from the position of the last segment in the path to
|
|
554
|
+
* the specified point, by adding one or more segments to the path.
|
|
555
|
+
*
|
|
556
|
+
* @param to the point where the arc should end
|
|
557
|
+
* @param clockwise specifies whether the arc should be
|
|
558
|
+
* drawn in clockwise direction
|
|
559
|
+
* @return this path itself, so calls can be chained
|
|
560
|
+
* @chainable
|
|
561
|
+
*
|
|
562
|
+
* @example {@paperscript}
|
|
563
|
+
* var path = new Path();
|
|
564
|
+
* path.strokeColor = 'black';
|
|
565
|
+
*
|
|
566
|
+
* path.add(new Point(30, 75));
|
|
567
|
+
* path.arcTo(new Point(130, 75));
|
|
568
|
+
*
|
|
569
|
+
* var path2 = new Path();
|
|
570
|
+
* path2.strokeColor = 'red';
|
|
571
|
+
* path2.add(new Point(180, 25));
|
|
572
|
+
*
|
|
573
|
+
* // To draw an arc in anticlockwise direction,
|
|
574
|
+
* // we pass `false` as the second argument to arcTo:
|
|
575
|
+
* path2.arcTo(new Point(280, 25), false);
|
|
576
|
+
*
|
|
577
|
+
* @example {@paperscript height=300}
|
|
578
|
+
* // Interactive example. Click and drag in the view below:
|
|
579
|
+
* var myPath;
|
|
580
|
+
*
|
|
581
|
+
* // The mouse has to move at least 20 points before
|
|
582
|
+
* // the next mouse drag event is fired:
|
|
583
|
+
* tool.minDistance = 20;
|
|
584
|
+
*
|
|
585
|
+
* // When the user clicks, create a new path and add
|
|
586
|
+
* // the current mouse position to it as its first segment:
|
|
587
|
+
* function onMouseDown(event) {
|
|
588
|
+
* myPath = new Path();
|
|
589
|
+
* myPath.strokeColor = 'black';
|
|
590
|
+
* myPath.add(event.point);
|
|
591
|
+
* }
|
|
592
|
+
*
|
|
593
|
+
* // On each mouse drag event, draw an arc to the current
|
|
594
|
+
* // position of the mouse:
|
|
595
|
+
* function onMouseDrag(event) {
|
|
596
|
+
* myPath.arcTo(event.point);
|
|
597
|
+
* }
|
|
598
|
+
*/
|
|
599
|
+
abstract arcTo(to: PointLike, clockwise?: boolean): this;
|
|
600
|
+
/**
|
|
601
|
+
* Adds an elliptical arc from the position of the last segment in the
|
|
602
|
+
* path to the specified point, as the arc command of SVG path data
|
|
603
|
+
* describes it, by adding one or more segments to the path. If one of
|
|
604
|
+
* the radii is `0`, a straight curve is added instead.
|
|
605
|
+
*
|
|
606
|
+
* @param to the point where the arc should end
|
|
607
|
+
* @param radius the horizontal and vertical radii of the ellipse, or
|
|
608
|
+
* one radius for both
|
|
609
|
+
* @param rotation the rotation of the ellipse in degrees
|
|
610
|
+
* @param clockwise specifies whether the arc should be drawn in
|
|
611
|
+
* clockwise direction
|
|
612
|
+
* @param large specifies whether the larger of the two possible arcs
|
|
613
|
+
* should be drawn
|
|
614
|
+
* @return this path itself, so calls can be chained
|
|
615
|
+
* @chainable
|
|
616
|
+
*
|
|
617
|
+
* @example {@paperscript}
|
|
618
|
+
* var path = new Path();
|
|
619
|
+
* path.strokeColor = 'black';
|
|
620
|
+
* path.add(new Point(30, 75));
|
|
621
|
+
*
|
|
622
|
+
* // Draw an elliptical arc, rotated by 30 degrees:
|
|
623
|
+
* path.arcTo(new Point(130, 75), new Size(60, 30), 30, true, false);
|
|
624
|
+
*/
|
|
625
|
+
abstract arcTo(to: PointLike, radius: SizeLike | number, rotation: number, clockwise: boolean, large: boolean): this;
|
|
626
|
+
/**
|
|
627
|
+
* Adds an arc that sweeps the specified angle around the specified
|
|
628
|
+
* `center` point, from the position of the last segment in the path, by
|
|
629
|
+
* adding one or more segments to the path. Positive angles draw the arc in
|
|
630
|
+
* clockwise direction, negative ones in anticlockwise direction.
|
|
631
|
+
*
|
|
632
|
+
* @param center the center of the arc
|
|
633
|
+
* @param angle the angle in degrees that the arc sweeps over
|
|
634
|
+
* @return this path itself, so calls can be chained
|
|
635
|
+
* @chainable
|
|
636
|
+
*
|
|
637
|
+
* @example {@paperscript}
|
|
638
|
+
* var path = new Path();
|
|
639
|
+
* path.strokeColor = 'black';
|
|
640
|
+
* path.add(new Point(30, 75));
|
|
641
|
+
* path.lineTo(new Point(80, 75));
|
|
642
|
+
*
|
|
643
|
+
* // Draw a half circle around (105, 75) and continue on the other side:
|
|
644
|
+
* path.arcAround(new Point(105, 75), 180);
|
|
645
|
+
* path.lineTo(new Point(180, 75));
|
|
646
|
+
*
|
|
647
|
+
* // Draw a full circle around (230, 75):
|
|
648
|
+
* var circle = new Path();
|
|
649
|
+
* circle.strokeColor = 'red';
|
|
650
|
+
* circle.add(new Point(250, 75));
|
|
651
|
+
* circle.arcAround(new Point(230, 75), 360);
|
|
652
|
+
*/
|
|
653
|
+
abstract arcAround(center: PointLike, angle: number): this;
|
|
654
|
+
/**
|
|
655
|
+
* Adds an arc from the position of the last segment in the path to the
|
|
656
|
+
* specified point, by adding one or more segments to the path. The arc
|
|
657
|
+
* continues in the direction in which the path ends, without a corner.
|
|
658
|
+
*
|
|
659
|
+
* @param to the point where the arc should end
|
|
660
|
+
* @return this path itself, so calls can be chained
|
|
661
|
+
* @chainable
|
|
662
|
+
*
|
|
663
|
+
* @example {@paperscript}
|
|
664
|
+
* var path = new Path();
|
|
665
|
+
* path.strokeColor = 'black';
|
|
666
|
+
* path.add(new Point(30, 125));
|
|
667
|
+
* path.lineTo(new Point(80, 125));
|
|
668
|
+
*
|
|
669
|
+
* // Each arc continues smoothly from where the path ends:
|
|
670
|
+
* path.arcTowards(new Point(130, 75));
|
|
671
|
+
* path.arcTowards(new Point(230, 75));
|
|
672
|
+
* path.lineTo(new Point(230, 125));
|
|
673
|
+
*
|
|
674
|
+
* @example {@paperscript height=300}
|
|
675
|
+
* // Interactive example. Click and drag in the view below:
|
|
676
|
+
* var myPath;
|
|
677
|
+
*
|
|
678
|
+
* // The mouse has to move at least 20 points before
|
|
679
|
+
* // the next mouse drag event is fired:
|
|
680
|
+
* tool.minDistance = 20;
|
|
681
|
+
*
|
|
682
|
+
* // When the user clicks, create a new path that starts
|
|
683
|
+
* // with a horizontal line ending at the mouse position:
|
|
684
|
+
* function onMouseDown(event) {
|
|
685
|
+
* myPath = new Path();
|
|
686
|
+
* myPath.strokeColor = 'black';
|
|
687
|
+
* myPath.add(event.point - [20, 0], event.point);
|
|
688
|
+
* }
|
|
689
|
+
*
|
|
690
|
+
* // On each mouse drag event, continue the path smoothly
|
|
691
|
+
* // with an arc to the current position of the mouse:
|
|
692
|
+
* function onMouseDrag(event) {
|
|
693
|
+
* myPath.arcTowards(event.point);
|
|
694
|
+
* }
|
|
695
|
+
*/
|
|
696
|
+
abstract arcTowards(to: PointLike | number, y?: number): this;
|
|
697
|
+
/**
|
|
698
|
+
* Adds a curve from the last segment in the path through the specified
|
|
699
|
+
* `through` point, to the specified destination point by adding one segment
|
|
700
|
+
* to the path.
|
|
701
|
+
*
|
|
702
|
+
* @param through the point through which the curve should pass
|
|
703
|
+
* @param to the destination point of the newly added curve
|
|
704
|
+
* @param time the curve-time parameter at which the
|
|
705
|
+
* `through` point is to be located
|
|
706
|
+
* @return this path itself, so calls can be chained
|
|
707
|
+
* @chainable
|
|
708
|
+
*
|
|
709
|
+
* @example {@paperscript height=300}
|
|
710
|
+
* // Interactive example. Move your mouse around the view below:
|
|
711
|
+
*
|
|
712
|
+
* var myPath;
|
|
713
|
+
* function onMouseMove(event) {
|
|
714
|
+
* // If we created a path before, remove it:
|
|
715
|
+
* if (myPath) {
|
|
716
|
+
* myPath.remove();
|
|
717
|
+
* }
|
|
718
|
+
*
|
|
719
|
+
* // Create a new path and add a segment point to it
|
|
720
|
+
* // at {x: 150, y: 150):
|
|
721
|
+
* myPath = new Path();
|
|
722
|
+
* myPath.add(new Point(150, 150));
|
|
723
|
+
*
|
|
724
|
+
* // Draw a curve through the position of the mouse to 'toPoint'
|
|
725
|
+
* var toPoint = new Point(350, 150);
|
|
726
|
+
* myPath.curveTo(event.point, toPoint);
|
|
727
|
+
*
|
|
728
|
+
* // Select the path, so we can see its segments:
|
|
729
|
+
* myPath.selected = true;
|
|
730
|
+
* }
|
|
731
|
+
*/
|
|
732
|
+
abstract curveTo(through: PointLike, to: PointLike, time?: number): this;
|
|
733
|
+
/**
|
|
734
|
+
* Adds a cubic bezier curve to the path, from the last segment to the
|
|
735
|
+
* specified destination point, with the curve itself defined by two
|
|
736
|
+
* specified handles.
|
|
737
|
+
*
|
|
738
|
+
* The points can also be passed as their coordinates, as canvas takes them:
|
|
739
|
+
* `cubicCurveTo(x1, y1, x2, y2, x, y)`.
|
|
740
|
+
*
|
|
741
|
+
* @param handle1 the location of the first handle of the newly
|
|
742
|
+
* added curve in absolute coordinates, out of which the relative values
|
|
743
|
+
* for {@link Segment#handleOut} of its first segment are calculated
|
|
744
|
+
* @param handle2 the location of the second handle of the newly
|
|
745
|
+
* added curve in absolute coordinates, out of which the relative values
|
|
746
|
+
* for {@link Segment#handleIn} of its second segment are calculated
|
|
747
|
+
* @param to the destination point of the newly added curve
|
|
748
|
+
* @return this path itself, so calls can be chained
|
|
749
|
+
* @chainable
|
|
750
|
+
*/
|
|
751
|
+
abstract cubicCurveTo(handle1: PointLike, handle2: PointLike, to: PointLike): this;
|
|
752
|
+
abstract cubicCurveTo(...coordinates: CubicCoordinates): this;
|
|
753
|
+
/**
|
|
754
|
+
* Adds a quadratic bezier curve to the path, from the last segment to the
|
|
755
|
+
* specified destination point, with the curve itself defined by the
|
|
756
|
+
* specified handle.
|
|
757
|
+
*
|
|
758
|
+
* Note that Paper.js only stores cubic curves, so the handle is actually
|
|
759
|
+
* converted.
|
|
760
|
+
*
|
|
761
|
+
* The points can also be passed as their coordinates, as canvas takes them:
|
|
762
|
+
* `quadraticCurveTo(x1, y1, x, y)`.
|
|
763
|
+
*
|
|
764
|
+
* @param handle the location of the handle of the newly added
|
|
765
|
+
* quadratic curve in absolute coordinates, out of which the relative
|
|
766
|
+
* values for {@link Segment#handleOut} of the resulting cubic curve's
|
|
767
|
+
* first segment and {@link Segment#handleIn} of its second segment are
|
|
768
|
+
* calculated
|
|
769
|
+
* @param to the destination point of the newly added curve
|
|
770
|
+
* @return this path itself, so calls can be chained
|
|
771
|
+
* @chainable
|
|
772
|
+
*/
|
|
773
|
+
abstract quadraticCurveTo(handle: PointLike, to: PointLike): this;
|
|
774
|
+
abstract quadraticCurveTo(...coordinates: QuadraticCoordinates): this;
|
|
775
|
+
/**
|
|
776
|
+
* Closes the path. When closed, Paper.js connects the first and last
|
|
777
|
+
* segment of the path with an additional curve. The difference to setting
|
|
778
|
+
* {@link Path#closed} to `true` is that this will also merge the first
|
|
779
|
+
* segment with the last if they lie in the same location.
|
|
780
|
+
*
|
|
781
|
+
* @param [tolerance=0] the tolerance with which to decide if the first
|
|
782
|
+
* and last segments are to be considered the same location
|
|
783
|
+
* @see Path#closed
|
|
784
|
+
* @return this path itself, so calls can be chained
|
|
785
|
+
* @chainable
|
|
786
|
+
*/
|
|
787
|
+
abstract closePath(tolerance?: number): this;
|
|
788
|
+
/**
|
|
789
|
+
* {@grouptitle Relative Drawing Commands}
|
|
790
|
+
*
|
|
791
|
+
* If called on a {@link CompoundPath}, a new {@link Path} is created as a
|
|
792
|
+
* child and a point is added as its first segment relative to the position
|
|
793
|
+
* of the last segment of the current path.
|
|
794
|
+
*
|
|
795
|
+
* @param to the vector describing the position of the new path's first
|
|
796
|
+
* segment, relative to the last segment of the current path
|
|
797
|
+
* @return this path itself, so calls can be chained
|
|
798
|
+
* @chainable
|
|
799
|
+
*/
|
|
800
|
+
abstract moveBy(to: PointLike | number, y?: number): this;
|
|
801
|
+
/**
|
|
802
|
+
* Adds a straight curve to the path, from the last segment in the path
|
|
803
|
+
* to the `point` vector specified relatively to it.
|
|
804
|
+
*
|
|
805
|
+
* @param point the vector describing the destination of the newly
|
|
806
|
+
* added straight curve
|
|
807
|
+
* @return this path itself, so calls can be chained
|
|
808
|
+
* @chainable
|
|
809
|
+
*
|
|
810
|
+
* @example {@paperscript}
|
|
811
|
+
* var path = new Path();
|
|
812
|
+
* path.strokeColor = 'black';
|
|
813
|
+
*
|
|
814
|
+
* // Add a segment at {x: 25, y: 25}
|
|
815
|
+
* path.add(new Point(25, 25));
|
|
816
|
+
*
|
|
817
|
+
* // Add a segment relative to the last segment of the path.
|
|
818
|
+
* // 50 in x direction and 0 in y direction, becomes {x: 75, y: 25}
|
|
819
|
+
* path.lineBy(50, 0);
|
|
820
|
+
*
|
|
821
|
+
* // 0 in x direction and 50 in y direction, becomes {x: 75, y: 75}
|
|
822
|
+
* path.lineBy(0, 50);
|
|
823
|
+
*
|
|
824
|
+
* @example {@paperscript height=300}
|
|
825
|
+
* // Drawing a spiral using lineBy:
|
|
826
|
+
* var path = new Path();
|
|
827
|
+
* path.strokeColor = 'black';
|
|
828
|
+
*
|
|
829
|
+
* // Add the first segment at {x: 50, y: 50}
|
|
830
|
+
* path.add(view.center);
|
|
831
|
+
*
|
|
832
|
+
* // Loop 500 times:
|
|
833
|
+
* for (var i = 0; i < 500; i++) {
|
|
834
|
+
* // Create a vector with an ever increasing length
|
|
835
|
+
* // and an angle in increments of 45 degrees
|
|
836
|
+
* var vector = new Point({
|
|
837
|
+
* angle: i * 45,
|
|
838
|
+
* length: i / 2
|
|
839
|
+
* });
|
|
840
|
+
* // Add the vector relatively to the last segment point:
|
|
841
|
+
* path.lineBy(vector);
|
|
842
|
+
* }
|
|
843
|
+
*
|
|
844
|
+
* // Smooth the handles of the path:
|
|
845
|
+
* path.smooth();
|
|
846
|
+
*
|
|
847
|
+
* // Uncomment the following line and click on 'run' to see
|
|
848
|
+
* // the construction of the path:
|
|
849
|
+
* // path.selected = true;
|
|
850
|
+
*/
|
|
851
|
+
abstract lineBy(point: PointLike | number, y?: number): this;
|
|
852
|
+
/**
|
|
853
|
+
* Adds an arc from the position of the last segment in the path, passing
|
|
854
|
+
* through the specified `through` vector, to the specified `to` vector, all
|
|
855
|
+
* specified relatively to it by these given vectors, by adding one or more
|
|
856
|
+
* segments to the path.
|
|
857
|
+
*
|
|
858
|
+
* @param through the vector where the arc should pass through
|
|
859
|
+
* @param to the vector where the arc should end
|
|
860
|
+
* @return this path itself, so calls can be chained
|
|
861
|
+
* @chainable
|
|
862
|
+
*/
|
|
863
|
+
abstract arcBy(through: PointLike, to: PointLike): this;
|
|
864
|
+
/**
|
|
865
|
+
* Adds an arc from the position of the last segment in the path to the `to`
|
|
866
|
+
* vector specified relatively to it, by adding one or more segments to the
|
|
867
|
+
* path.
|
|
868
|
+
*
|
|
869
|
+
* @param to the vector where the arc should end
|
|
870
|
+
* @param clockwise specifies whether the arc should be
|
|
871
|
+
* drawn in clockwise direction
|
|
872
|
+
* @return this path itself, so calls can be chained
|
|
873
|
+
* @chainable
|
|
874
|
+
*/
|
|
875
|
+
abstract arcBy(to: PointLike, clockwise?: boolean): this;
|
|
876
|
+
/**
|
|
877
|
+
* Adds a curve from the last segment in the path through the specified
|
|
878
|
+
* `through` vector, to the specified `to` vector, all specified relatively
|
|
879
|
+
* to it by these given vectors, by adding one segment to the path.
|
|
880
|
+
*
|
|
881
|
+
* @param through the vector through which the curve should pass
|
|
882
|
+
* @param to the destination vector of the newly added curve
|
|
883
|
+
* @param time the curve-time parameter at which the
|
|
884
|
+
* `through` point is to be located
|
|
885
|
+
* @return this path itself, so calls can be chained
|
|
886
|
+
* @chainable
|
|
887
|
+
*/
|
|
888
|
+
abstract curveBy(through: PointLike, to: PointLike, time?: number): this;
|
|
889
|
+
/**
|
|
890
|
+
* Adds a cubic bezier curve to the path, from the last segment to the
|
|
891
|
+
* specified `to` vector, with the curve itself defined by two
|
|
892
|
+
* specified handles.
|
|
893
|
+
*
|
|
894
|
+
* The points can also be passed as their coordinates:
|
|
895
|
+
* `cubicCurveBy(x1, y1, x2, y2, x, y)`.
|
|
896
|
+
*
|
|
897
|
+
* @param handle1 the location of the first handle of the newly
|
|
898
|
+
* added curve
|
|
899
|
+
* @param handle2 the location of the second handle of the newly
|
|
900
|
+
* added curve
|
|
901
|
+
* @param to the destination point of the newly added curve
|
|
902
|
+
* @return this path itself, so calls can be chained
|
|
903
|
+
* @chainable
|
|
904
|
+
*/
|
|
905
|
+
abstract cubicCurveBy(handle1: PointLike, handle2: PointLike, to: PointLike): this;
|
|
906
|
+
abstract cubicCurveBy(...coordinates: CubicCoordinates): this;
|
|
907
|
+
/**
|
|
908
|
+
* Adds a quadratic bezier curve to the path, from the last segment to the
|
|
909
|
+
* specified destination point, with the curve itself defined by the
|
|
910
|
+
* specified handle.
|
|
911
|
+
*
|
|
912
|
+
* Note that Paper.js only stores cubic curves, so the handle is actually
|
|
913
|
+
* converted.
|
|
914
|
+
*
|
|
915
|
+
* The points can also be passed as their coordinates:
|
|
916
|
+
* `quadraticCurveBy(x1, y1, x, y)`.
|
|
917
|
+
*
|
|
918
|
+
* @param handle the handle of the newly added quadratic curve out
|
|
919
|
+
* of which the values for {@link Segment#handleOut} of the resulting
|
|
920
|
+
* cubic curve's first segment and {@link Segment#handleIn} of its
|
|
921
|
+
* second segment are calculated
|
|
922
|
+
* @param to the destination point of the newly added curve
|
|
923
|
+
* @return this path itself, so calls can be chained
|
|
924
|
+
* @chainable
|
|
925
|
+
*/
|
|
926
|
+
abstract quadraticCurveBy(handle: PointLike, to: PointLike): this;
|
|
927
|
+
abstract quadraticCurveBy(...coordinates: QuadraticCoordinates): this;
|
|
928
|
+
abstract _getPaths(): Path[];
|
|
929
|
+
static _createGraph(path1: PathItem, path2?: PathItem): Graph;
|
|
930
|
+
/**
|
|
931
|
+
* {@grouptitle Boolean Path Operations}
|
|
932
|
+
*
|
|
933
|
+
* Unites the geometry of the specified path with this path's geometry
|
|
934
|
+
* and returns the result as a new path item. With an array of paths,
|
|
935
|
+
* the result covers the areas inside any of them or this path. Each
|
|
936
|
+
* path keeps its own fill rule.
|
|
937
|
+
*
|
|
938
|
+
* @option [options.insert=true] {Boolean} whether the resulting item
|
|
939
|
+
* should be inserted back into the scene graph, above all paths
|
|
940
|
+
* involved in the operation
|
|
941
|
+
*
|
|
942
|
+
* @param path the path or paths to unite with
|
|
943
|
+
* @param options the boolean operation options
|
|
944
|
+
* @return the resulting path item
|
|
945
|
+
*
|
|
946
|
+
* @example {@paperscript}
|
|
947
|
+
* var result = Path.regularPolygon([50, 50], 3, 40)
|
|
948
|
+
* .unite(Path.circle([50, 50], 25));
|
|
949
|
+
* result.fillColor = 'red';
|
|
950
|
+
*
|
|
951
|
+
* @example {@paperscript}
|
|
952
|
+
* // Uniting many paths at once:
|
|
953
|
+
* var circles = [];
|
|
954
|
+
* for (var i = 0; i < 6; i++) {
|
|
955
|
+
* circles.push(Path.circle([30 + i * 20, 50], 20));
|
|
956
|
+
* }
|
|
957
|
+
* var result = circles[0].unite(circles.slice(1));
|
|
958
|
+
* result.fillColor = 'red';
|
|
959
|
+
*/
|
|
960
|
+
unite(path?: PathItem | PathItem[], options?: BooleanOptions): PathItem;
|
|
961
|
+
/**
|
|
962
|
+
* Intersects the geometry of the specified path with this path's
|
|
963
|
+
* geometry and returns the result as a new path item. With an array of
|
|
964
|
+
* paths, the result covers the areas inside all of them and this path.
|
|
965
|
+
* Each path keeps its own fill rule.
|
|
966
|
+
*
|
|
967
|
+
* @option [options.insert=true] {Boolean} whether the resulting item
|
|
968
|
+
* should be inserted back into the scene graph, above all paths
|
|
969
|
+
* involved in the operation
|
|
970
|
+
* @option [options.trace=true] {Boolean} whether the tracing method is
|
|
971
|
+
* used, treating all paths as areas when determining which parts
|
|
972
|
+
* of the paths are to be kept in the result, or whether the first
|
|
973
|
+
* path is only to be split at intersections, keeping the parts of
|
|
974
|
+
* the curves that intersect with the areas of all other paths.
|
|
975
|
+
*
|
|
976
|
+
* @param path the path or paths to intersect
|
|
977
|
+
* with
|
|
978
|
+
* @param options the boolean operation options
|
|
979
|
+
* @return the resulting path item
|
|
980
|
+
*
|
|
981
|
+
* @example {@paperscript}
|
|
982
|
+
* var result = Path.regularPolygon([50, 50], 3, 40)
|
|
983
|
+
* .intersect(Path.circle([50, 50], 25));
|
|
984
|
+
* result.fillColor = 'red';
|
|
985
|
+
*/
|
|
986
|
+
intersect(path: PathItem | PathItem[], options?: BooleanOptions): PathItem;
|
|
987
|
+
/**
|
|
988
|
+
* Subtracts the geometry of the specified path from this path's
|
|
989
|
+
* geometry and returns the result as a new path item. With an array of
|
|
990
|
+
* paths, the result covers the areas inside this path and outside all
|
|
991
|
+
* of them. Each path keeps its own fill rule.
|
|
992
|
+
*
|
|
993
|
+
* @option [options.insert=true] {Boolean} whether the resulting item
|
|
994
|
+
* should be inserted back into the scene graph, above all paths
|
|
995
|
+
* involved in the operation
|
|
996
|
+
* @option [options.trace=true] {Boolean} whether the tracing method is
|
|
997
|
+
* used, treating all paths as areas when determining which parts
|
|
998
|
+
* of the paths are to be kept in the result, or whether the first
|
|
999
|
+
* path is only to be split at intersections, removing the parts of
|
|
1000
|
+
* the curves that intersect with the area of any other path.
|
|
1001
|
+
*
|
|
1002
|
+
* @param path the path or paths to subtract
|
|
1003
|
+
* @param options the boolean operation options
|
|
1004
|
+
* @return the resulting path item
|
|
1005
|
+
*
|
|
1006
|
+
* @example {@paperscript}
|
|
1007
|
+
* var result = Path.regularPolygon([50, 50], 3, 40)
|
|
1008
|
+
* .subtract(Path.circle([50, 50], 25));
|
|
1009
|
+
* result.fillColor = 'red';
|
|
1010
|
+
*/
|
|
1011
|
+
subtract(path: PathItem | PathItem[], options?: BooleanOptions): PathItem;
|
|
1012
|
+
/**
|
|
1013
|
+
* Excludes the intersection of the geometry of the specified path with
|
|
1014
|
+
* this path's geometry and returns the result as a new path item. With
|
|
1015
|
+
* an array of paths, the result covers the areas inside an odd number
|
|
1016
|
+
* of the paths, this one included. Each path keeps its own fill rule.
|
|
1017
|
+
*
|
|
1018
|
+
* @option [options.insert=true] {Boolean} whether the resulting item
|
|
1019
|
+
* should be inserted back into the scene graph, above all paths
|
|
1020
|
+
* involved in the operation
|
|
1021
|
+
*
|
|
1022
|
+
* @param path the path or paths to exclude the
|
|
1023
|
+
* intersection of
|
|
1024
|
+
* @param options the boolean operation options
|
|
1025
|
+
* @return the resulting path item
|
|
1026
|
+
*
|
|
1027
|
+
* @example {@paperscript}
|
|
1028
|
+
* var result = Path.regularPolygon([50, 50], 3, 40)
|
|
1029
|
+
* .exclude(Path.circle([50, 50], 25));
|
|
1030
|
+
* result.fillColor = 'red';
|
|
1031
|
+
*/
|
|
1032
|
+
exclude(path: PathItem | PathItem[], options?: BooleanOptions): PathItem;
|
|
1033
|
+
/**
|
|
1034
|
+
* Splits the geometry of this path along the geometry of the specified
|
|
1035
|
+
* path and returns the result as a new group item. This is equivalent to
|
|
1036
|
+
* calling {@link #subtract(path)} and {@link #intersect(path)} and
|
|
1037
|
+
* putting the results into a new group.
|
|
1038
|
+
*
|
|
1039
|
+
* @option [options.insert=true] {Boolean} whether the resulting item
|
|
1040
|
+
* should be inserted back into the scene graph, above both paths
|
|
1041
|
+
* involved in the operation
|
|
1042
|
+
* @option [options.trace=true] {Boolean} whether the tracing method is
|
|
1043
|
+
* used, treating both paths as areas when determining which parts
|
|
1044
|
+
* of the paths are to be kept in the result, or whether the first
|
|
1045
|
+
* path is only to be split at intersections.
|
|
1046
|
+
*
|
|
1047
|
+
* @param path the path to divide by
|
|
1048
|
+
* @param options the boolean operation options
|
|
1049
|
+
* @return the resulting path item
|
|
1050
|
+
*/
|
|
1051
|
+
divide(path: PathItem, options?: BooleanOptions): PathItem;
|
|
1052
|
+
resolveCrossings(): PathItem;
|
|
1053
|
+
/**
|
|
1054
|
+
* Fixes the orientation of the sub-paths of a compound-path, by
|
|
1055
|
+
* reorienting them so that they are of different winding direction than
|
|
1056
|
+
* their containing paths, except for disjoint sub-paths, i.e. islands,
|
|
1057
|
+
* which are oriented so that they have the same winding direction as the
|
|
1058
|
+
* biggest path. Sub-paths that touch or cross each other are replaced by
|
|
1059
|
+
* the outlines of the area that they fill.
|
|
1060
|
+
*
|
|
1061
|
+
* @option [options.fillRule=item.fillRule] {String} the fill rule that
|
|
1062
|
+
* decides the area the sub-paths fill: with `'nonzero'`, sub-paths
|
|
1063
|
+
* that do not add to the area are discarded
|
|
1064
|
+
* {@values 'nonzero', 'evenodd'}
|
|
1065
|
+
* @option options.clockwise {Boolean} if provided, the orientation of the
|
|
1066
|
+
* root paths, otherwise the orientation of the largest root child is
|
|
1067
|
+
* used
|
|
1068
|
+
*
|
|
1069
|
+
* @param [options] the options of the reorientation
|
|
1070
|
+
* @return a reference to the item itself, reoriented
|
|
1071
|
+
*/
|
|
1072
|
+
reorient({ fillRule, clockwise }?: {
|
|
1073
|
+
fillRule?: FillRule;
|
|
1074
|
+
clockwise?: boolean;
|
|
1075
|
+
}): this;
|
|
1076
|
+
/**
|
|
1077
|
+
* {@grouptitle Offsetting and Outlining}
|
|
1078
|
+
*
|
|
1079
|
+
* Offsets the path item by the given distance and returns the result
|
|
1080
|
+
* as a new path item. Closed paths and compound paths grow by positive
|
|
1081
|
+
* distances and shrink by negative ones, open paths are offset along
|
|
1082
|
+
* their normals for positive distances, and against them for negative
|
|
1083
|
+
* ones. As with the boolean operations, the path item's matrix is
|
|
1084
|
+
* applied first.
|
|
1085
|
+
*
|
|
1086
|
+
* @option [options.join='miter'] {String} the shape of the corners
|
|
1087
|
+
* that the offset adds where the path turns away from it:
|
|
1088
|
+
* {@values 'miter', 'round', 'bevel'}
|
|
1089
|
+
* @option [options.miterLimit=10] {Number} the limit of miter corners,
|
|
1090
|
+
* see {@link Style#miterLimit}
|
|
1091
|
+
* @option [options.insert=true] {Boolean} whether the resulting item
|
|
1092
|
+
* should be inserted back into the scene graph, above this path
|
|
1093
|
+
*
|
|
1094
|
+
* @param distance the distance to offset the path item by
|
|
1095
|
+
* @param options the offset options
|
|
1096
|
+
* @return the resulting path item
|
|
1097
|
+
*
|
|
1098
|
+
* @example {@paperscript}
|
|
1099
|
+
* var path = Path.star([50, 50], 5, 20, 40);
|
|
1100
|
+
* path.strokeColor = 'black';
|
|
1101
|
+
* var result = path.offset(10, { join: 'round' });
|
|
1102
|
+
* result.strokeColor = 'red';
|
|
1103
|
+
*/
|
|
1104
|
+
offset(distance: number, options?: PathOffsetOptions): PathItem;
|
|
1105
|
+
/**
|
|
1106
|
+
* Outlines the stroke of the path item, and returns the area that it
|
|
1107
|
+
* covers as a new path item, filled with the stroke's color. As with
|
|
1108
|
+
* the boolean operations, the path item's matrix is applied first.
|
|
1109
|
+
* Dashed strokes are outlined as their dashes, each with the stroke's
|
|
1110
|
+
* caps, as the canvas draws them, see {@link #dash(options)}.
|
|
1111
|
+
*
|
|
1112
|
+
* Paths with a {@link Path#strokeProfile} are outlined as the area
|
|
1113
|
+
* that its pens sweep. Their round joins and caps are the pens
|
|
1114
|
+
* themselves, and their other joins and caps connect the points where
|
|
1115
|
+
* the pens touch the sides of the stroke. Steps in the profile end
|
|
1116
|
+
* the parts of the stroke straight across, as butt caps do.
|
|
1117
|
+
*
|
|
1118
|
+
* @option [options.width=this.strokeWidth] {Number} the width of the
|
|
1119
|
+
* stroke
|
|
1120
|
+
* @option [options.join=this.strokeJoin] {String} the shape of the
|
|
1121
|
+
* stroke's corners: {@values 'miter', 'round', 'bevel'}
|
|
1122
|
+
* @option [options.cap=this.strokeCap] {String} the shape of the
|
|
1123
|
+
* stroke's ends: {@values 'round', 'square', 'butt'}
|
|
1124
|
+
* @option [options.miterLimit=this.miterLimit] {Number} the limit of
|
|
1125
|
+
* miter corners, see {@link Style#miterLimit}
|
|
1126
|
+
* @option [options.dashArray=this.dashArray] {Number[]} the lengths of
|
|
1127
|
+
* the stroke's dashes and gaps
|
|
1128
|
+
* @option [options.dashOffset=this.dashOffset] {Number} the offset of
|
|
1129
|
+
* the dashes
|
|
1130
|
+
* @option [options.insert=true] {Boolean} whether the resulting item
|
|
1131
|
+
* should be inserted back into the scene graph, above this path
|
|
1132
|
+
*
|
|
1133
|
+
* @param options the outline options
|
|
1134
|
+
* @return the resulting path item
|
|
1135
|
+
*
|
|
1136
|
+
* @example {@paperscript}
|
|
1137
|
+
* var path = Path.arc([20, 70], [50, 20], [80, 70]);
|
|
1138
|
+
* path.strokeColor = 'black';
|
|
1139
|
+
* path.strokeWidth = 20;
|
|
1140
|
+
* path.strokeCap = 'round';
|
|
1141
|
+
* var result = path.outline();
|
|
1142
|
+
* result.strokeColor = 'red';
|
|
1143
|
+
* result.strokeWidth = 1;
|
|
1144
|
+
* path.remove();
|
|
1145
|
+
*/
|
|
1146
|
+
outline(options?: PathOutlineOptions): PathItem;
|
|
1147
|
+
/**
|
|
1148
|
+
* Cuts the stroke of the path item into its dashes, as the canvas draws
|
|
1149
|
+
* them with the {@link Style#dashArray} and {@link Style#dashOffset}
|
|
1150
|
+
* of the path item or those of the options, and returns them as a new
|
|
1151
|
+
* group of open paths with the path item's style, without its dash
|
|
1152
|
+
* pattern. The pattern starts over on each path of a compound path,
|
|
1153
|
+
* and the dashes keep the parts of the paths' stroke profiles. As with
|
|
1154
|
+
* the boolean operations, the path item's matrix is applied first.
|
|
1155
|
+
*
|
|
1156
|
+
* @option [options.dashArray=this.dashArray] {Number[]} the lengths of
|
|
1157
|
+
* the dashes and the gaps between them
|
|
1158
|
+
* @option [options.dashOffset=this.dashOffset] {Number} the offset
|
|
1159
|
+
* into the pattern at which the dashes start
|
|
1160
|
+
* @option [options.insert=true] {Boolean} whether the resulting group
|
|
1161
|
+
* should be inserted back into the scene graph, above this path
|
|
1162
|
+
* item
|
|
1163
|
+
*
|
|
1164
|
+
* @param options the dash options
|
|
1165
|
+
* @return the dashes, as a new group of paths
|
|
1166
|
+
*
|
|
1167
|
+
* @example {@paperscript}
|
|
1168
|
+
* var path = Path.circle({
|
|
1169
|
+
* center: [80, 50],
|
|
1170
|
+
* radius: 35,
|
|
1171
|
+
* strokeColor: 'black',
|
|
1172
|
+
* strokeWidth: 4,
|
|
1173
|
+
* dashArray: [12, 6]
|
|
1174
|
+
* });
|
|
1175
|
+
* // Turn every other dash red:
|
|
1176
|
+
* var dashes = path.dash();
|
|
1177
|
+
* dashes.children.forEach(function(dash, i) {
|
|
1178
|
+
* if (i % 2)
|
|
1179
|
+
* dash.strokeColor = 'red';
|
|
1180
|
+
* });
|
|
1181
|
+
* path.remove();
|
|
1182
|
+
*/
|
|
1183
|
+
dash(options?: DashOptions): Group;
|
|
1184
|
+
abstract get closed(): boolean;
|
|
1185
|
+
abstract set closed(closed: boolean);
|
|
1186
|
+
abstract get area(): number;
|
|
1187
|
+
abstract get length(): number;
|
|
1188
|
+
abstract get curves(): Curve[];
|
|
1189
|
+
}
|
|
1190
|
+
export declare function getPathData(item: PathItem, precision?: number): string;
|