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,457 @@
|
|
|
1
|
+
import { Formatter } from '../util/Formatter.ts';
|
|
2
|
+
import { Base } from '../core/Base.ts';
|
|
3
|
+
import type { Point } from './Point.ts';
|
|
4
|
+
/**
|
|
5
|
+
* What a size can be passed as, where a function takes one.
|
|
6
|
+
*/
|
|
7
|
+
export type SizeLike = Size | number[] | {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
} | {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The Size object is used to describe the size or dimensions of something,
|
|
16
|
+
* through its {@link #width} and {@link #height} properties.
|
|
17
|
+
*
|
|
18
|
+
* Wherever a size is the only argument of a function, it can also be passed
|
|
19
|
+
* as two numbers, e.g. `size.multiply(2, 3)`.
|
|
20
|
+
*
|
|
21
|
+
* @classexample
|
|
22
|
+
* // Create a size that is 10pt wide and 5pt high,
|
|
23
|
+
* // and use it to define a rectangle:
|
|
24
|
+
* var size = new Size(10, 5);
|
|
25
|
+
* console.log(size.width); // 10
|
|
26
|
+
* console.log(size.height); // 5
|
|
27
|
+
* var rect = new Rectangle(new Point(20, 15), size);
|
|
28
|
+
* console.log(rect); // { x: 20, y: 15, width: 10, height: 5 }
|
|
29
|
+
*/
|
|
30
|
+
export declare class Size extends Base {
|
|
31
|
+
/**
|
|
32
|
+
* The width of the size
|
|
33
|
+
*/
|
|
34
|
+
width: number;
|
|
35
|
+
/**
|
|
36
|
+
* The height of the size
|
|
37
|
+
*/
|
|
38
|
+
height: number;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Size object with the given width and height values.
|
|
41
|
+
*
|
|
42
|
+
* @param width the width
|
|
43
|
+
* @param [height=width] the height
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Create a size that is 10pt wide and 5pt high
|
|
47
|
+
* var size = new Size(10, 5);
|
|
48
|
+
* console.log(size.width); // 10
|
|
49
|
+
* console.log(size.height); // 5
|
|
50
|
+
*/
|
|
51
|
+
constructor(width: number, height?: number);
|
|
52
|
+
/**
|
|
53
|
+
* Creates a Size object using the numbers in the given array as
|
|
54
|
+
* dimensions.
|
|
55
|
+
*
|
|
56
|
+
* @param array
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Creating a size of width: 320, height: 240 using an array of numbers:
|
|
60
|
+
* var array = [320, 240];
|
|
61
|
+
* var size = new Size(array);
|
|
62
|
+
* console.log(size.width); // 320
|
|
63
|
+
* console.log(size.height); // 240
|
|
64
|
+
*/
|
|
65
|
+
constructor(array: number[]);
|
|
66
|
+
/**
|
|
67
|
+
* Creates a Size object using the properties in the given object.
|
|
68
|
+
*
|
|
69
|
+
* @param object
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Creating a size of width: 10, height: 20 using an object literal:
|
|
73
|
+
*
|
|
74
|
+
* var size = new Size({
|
|
75
|
+
* width: 10,
|
|
76
|
+
* height: 20
|
|
77
|
+
* });
|
|
78
|
+
* console.log(size.width); // 10
|
|
79
|
+
* console.log(size.height); // 20
|
|
80
|
+
*/
|
|
81
|
+
constructor(object: {
|
|
82
|
+
width: number;
|
|
83
|
+
height: number;
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Creates a Size object using the coordinates of the given Size object.
|
|
87
|
+
*
|
|
88
|
+
* @param size
|
|
89
|
+
*/
|
|
90
|
+
constructor(size?: Size);
|
|
91
|
+
/**
|
|
92
|
+
* Creates a Size object using the {@link Point#x} and {@link Point#y}
|
|
93
|
+
* values of the given Point object.
|
|
94
|
+
*
|
|
95
|
+
* @param point
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* var point = new Point(50, 50);
|
|
99
|
+
* var size = new Size(point);
|
|
100
|
+
* console.log(size.width); // 50
|
|
101
|
+
* console.log(size.height); // 50
|
|
102
|
+
*/
|
|
103
|
+
constructor(point: Point);
|
|
104
|
+
constructor(size: SizeLike | number, height?: number);
|
|
105
|
+
/**
|
|
106
|
+
* Sets the size to the passed values. Note that any sequence of parameters
|
|
107
|
+
* that is supported by the various {@link Size()} constructors also work
|
|
108
|
+
* for calls of `set()`.
|
|
109
|
+
*
|
|
110
|
+
* @param size the size, or its width
|
|
111
|
+
* @param height the height, with a number as the first argument
|
|
112
|
+
*/
|
|
113
|
+
set(size?: SizeLike | number, height?: number): this;
|
|
114
|
+
_set(width: number, height: number): this;
|
|
115
|
+
/**
|
|
116
|
+
* Checks whether the width and height of the size are equal to those of the
|
|
117
|
+
* supplied size.
|
|
118
|
+
*
|
|
119
|
+
* @param size the size to compare to
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* var size = new Size(5, 10);
|
|
123
|
+
* console.log(size == new Size(5, 10)); // true
|
|
124
|
+
* console.log(size == new Size(1, 1)); // false
|
|
125
|
+
* console.log(size != new Size(1, 1)); // true
|
|
126
|
+
*/
|
|
127
|
+
equals(size: SizeLike | null | undefined): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Returns a copy of the size.
|
|
130
|
+
*/
|
|
131
|
+
clone(): Size;
|
|
132
|
+
/**
|
|
133
|
+
* @return a string representation of the size
|
|
134
|
+
*/
|
|
135
|
+
toString(): string;
|
|
136
|
+
_serialize(options: {
|
|
137
|
+
formatter: Formatter;
|
|
138
|
+
}): number[];
|
|
139
|
+
/**
|
|
140
|
+
* The size's dimensions as an array, `[width, height]`, as
|
|
141
|
+
* {@link Matrix#values} gives those of a matrix.
|
|
142
|
+
*/
|
|
143
|
+
get values(): number[];
|
|
144
|
+
/**
|
|
145
|
+
* Returns the addition of the supplied value to the width and height of the
|
|
146
|
+
* size as a new size. The object itself is not modified!
|
|
147
|
+
*
|
|
148
|
+
* @operator
|
|
149
|
+
* @param number the number to add
|
|
150
|
+
* @return the addition of the size and the value as a new size
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* var size = new Size(5, 10);
|
|
154
|
+
* var result = size + 20; // PaperScript
|
|
155
|
+
* var result = size.add(20); // JavaScript
|
|
156
|
+
* console.log(result); // {width: 25, height: 30}
|
|
157
|
+
*/
|
|
158
|
+
add(number: number): Size;
|
|
159
|
+
/**
|
|
160
|
+
* Returns the addition of the width and height of the supplied size to the
|
|
161
|
+
* size as a new size. The object itself is not modified!
|
|
162
|
+
*
|
|
163
|
+
* @operator
|
|
164
|
+
* @param size the size to add
|
|
165
|
+
* @return the addition of the two sizes as a new size
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* var size1 = new Size(5, 10);
|
|
169
|
+
* var size2 = new Size(10, 20);
|
|
170
|
+
* var result = size1 + size2; // PaperScript
|
|
171
|
+
* var result = size1.add(size2); // JavaScript
|
|
172
|
+
* console.log(result); // {width: 15, height: 30}
|
|
173
|
+
*/
|
|
174
|
+
add(size: SizeLike): Size;
|
|
175
|
+
add(width: number, height: number): Size;
|
|
176
|
+
/**
|
|
177
|
+
* Returns the subtraction of the supplied value from the width and height
|
|
178
|
+
* of the size as a new size. The object itself is not modified!
|
|
179
|
+
*
|
|
180
|
+
* @operator
|
|
181
|
+
* @param number the number to subtract
|
|
182
|
+
* @return the subtraction of the size and the value as a new size
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* var size = new Size(10, 20);
|
|
186
|
+
* var result = size - 5; // PaperScript
|
|
187
|
+
* var result = size.subtract(5); // JavaScript
|
|
188
|
+
* console.log(result); // {width: 5, height: 15}
|
|
189
|
+
*/
|
|
190
|
+
subtract(number: number): Size;
|
|
191
|
+
/**
|
|
192
|
+
* Returns the subtraction of the width and height of the supplied size from
|
|
193
|
+
* the size as a new size. The object itself is not modified!
|
|
194
|
+
*
|
|
195
|
+
* @operator
|
|
196
|
+
* @param size the size to subtract
|
|
197
|
+
* @return the subtraction of the two sizes as a new size
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* var firstSize = new Size(10, 20);
|
|
201
|
+
* var secondSize = new Size(5, 5);
|
|
202
|
+
* var result = firstSize - secondSize; // PaperScript
|
|
203
|
+
* var result = firstSize.subtract(secondSize); // JavaScript
|
|
204
|
+
* console.log(result); // {width: 5, height: 15}
|
|
205
|
+
*/
|
|
206
|
+
subtract(size: SizeLike): Size;
|
|
207
|
+
subtract(width: number, height: number): Size;
|
|
208
|
+
/**
|
|
209
|
+
* Returns the multiplication of the supplied value with the width and
|
|
210
|
+
* height of the size as a new size. The object itself is not modified!
|
|
211
|
+
*
|
|
212
|
+
* @operator
|
|
213
|
+
* @param number the number to multiply by
|
|
214
|
+
* @return the multiplication of the size and the value as a new size
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* var size = new Size(10, 20);
|
|
218
|
+
* var result = size * 2; // PaperScript
|
|
219
|
+
* var result = size.multiply(2); // JavaScript
|
|
220
|
+
* console.log(result); // {width: 20, height: 40}
|
|
221
|
+
*/
|
|
222
|
+
multiply(number: number): Size;
|
|
223
|
+
/**
|
|
224
|
+
* Returns the multiplication of the width and height of the supplied size
|
|
225
|
+
* with the size as a new size. The object itself is not modified!
|
|
226
|
+
*
|
|
227
|
+
* @operator
|
|
228
|
+
* @param size the size to multiply by
|
|
229
|
+
* @return the multiplication of the two sizes as a new size
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* var firstSize = new Size(5, 10);
|
|
233
|
+
* var secondSize = new Size(4, 2);
|
|
234
|
+
* var result = firstSize * secondSize; // PaperScript
|
|
235
|
+
* var result = firstSize.multiply(secondSize); // JavaScript
|
|
236
|
+
* console.log(result); // {width: 20, height: 20}
|
|
237
|
+
*/
|
|
238
|
+
multiply(size: SizeLike): Size;
|
|
239
|
+
multiply(width: number, height: number): Size;
|
|
240
|
+
/**
|
|
241
|
+
* Returns the division of the supplied value by the width and height of the
|
|
242
|
+
* size as a new size. The object itself is not modified!
|
|
243
|
+
*
|
|
244
|
+
* @operator
|
|
245
|
+
* @param number the number to divide by
|
|
246
|
+
* @return the division of the size and the value as a new size
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* var size = new Size(10, 20);
|
|
250
|
+
* var result = size / 2; // PaperScript
|
|
251
|
+
* var result = size.divide(2); // JavaScript
|
|
252
|
+
* console.log(result); // {width: 5, height: 10}
|
|
253
|
+
*/
|
|
254
|
+
divide(number: number): Size;
|
|
255
|
+
/**
|
|
256
|
+
* Returns the division of the width and height of the supplied size by the
|
|
257
|
+
* size as a new size. The object itself is not modified!
|
|
258
|
+
*
|
|
259
|
+
* @operator
|
|
260
|
+
* @param size the size to divide by
|
|
261
|
+
* @return the division of the two sizes as a new size
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* var firstSize = new Size(8, 10);
|
|
265
|
+
* var secondSize = new Size(2, 5);
|
|
266
|
+
* var result = firstSize / secondSize; // PaperScript
|
|
267
|
+
* var result = firstSize.divide(secondSize); // JavaScript
|
|
268
|
+
* console.log(result); // {width: 4, height: 2}
|
|
269
|
+
*/
|
|
270
|
+
divide(size: SizeLike): Size;
|
|
271
|
+
divide(width: number, height: number): Size;
|
|
272
|
+
/**
|
|
273
|
+
* The modulo operator returns the integer remainders of dividing the size
|
|
274
|
+
* by the supplied value as a new size.
|
|
275
|
+
*
|
|
276
|
+
* @operator
|
|
277
|
+
* @param value
|
|
278
|
+
* @return the integer remainders of dividing the size by the value
|
|
279
|
+
* as a new size
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* var size = new Size(12, 6);
|
|
283
|
+
* var result = size % 5; // PaperScript
|
|
284
|
+
* var result = size.modulo(5); // JavaScript
|
|
285
|
+
* console.log(result); // {width: 2, height: 1}
|
|
286
|
+
*/
|
|
287
|
+
modulo(value: number): Size;
|
|
288
|
+
/**
|
|
289
|
+
* The modulo operator returns the integer remainders of dividing the size
|
|
290
|
+
* by the supplied size as a new size.
|
|
291
|
+
*
|
|
292
|
+
* @operator
|
|
293
|
+
* @param size
|
|
294
|
+
* @return the integer remainders of dividing the sizes by each
|
|
295
|
+
* other as a new size
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* var size = new Size(12, 6);
|
|
299
|
+
* var result = size % new Size(5, 2); // PaperScript
|
|
300
|
+
* var result = size.modulo(new Size(5, 2)); // JavaScript
|
|
301
|
+
* console.log(result); // {width: 2, height: 0}
|
|
302
|
+
*/
|
|
303
|
+
modulo(size: SizeLike): Size;
|
|
304
|
+
modulo(width: number, height: number): Size;
|
|
305
|
+
/**
|
|
306
|
+
* Returns a new size with both dimensions negated.
|
|
307
|
+
* PaperScript uses it for the unary minus operator.
|
|
308
|
+
* The object itself is not modified!
|
|
309
|
+
*
|
|
310
|
+
* @return the negation of the size as a new size
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* var size = new Size(12, -6);
|
|
314
|
+
* var result = -size; // PaperScript
|
|
315
|
+
* var result = size.negate(); // JavaScript
|
|
316
|
+
* console.log(result); // {width: -12, height: 6}
|
|
317
|
+
*/
|
|
318
|
+
negate(): Size;
|
|
319
|
+
/**
|
|
320
|
+
* {@grouptitle Tests}
|
|
321
|
+
* Checks if this size has both the width and height set to 0, within a
|
|
322
|
+
* tolerance of 1e-12, unlike {@link #equals(size)}, which compares
|
|
323
|
+
* exactly.
|
|
324
|
+
*
|
|
325
|
+
* @return {@true if both width and height are 0, within the tolerance}
|
|
326
|
+
*/
|
|
327
|
+
isZero(): boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Checks if the width or the height of the size are NaN.
|
|
330
|
+
*
|
|
331
|
+
* @return {@true if the width or height of the size are NaN}
|
|
332
|
+
*/
|
|
333
|
+
isNaN(): boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Returns the passed size if it is one already, or else a new size created
|
|
336
|
+
* from the passed values, as {@link Size()} reads them. A number makes a
|
|
337
|
+
* size only together with its height.
|
|
338
|
+
*
|
|
339
|
+
* @param size
|
|
340
|
+
* @param height
|
|
341
|
+
*/
|
|
342
|
+
static from(size: SizeLike | number, height?: number): Size;
|
|
343
|
+
/**
|
|
344
|
+
* Returns the passed size if it is one already, or else a new size created
|
|
345
|
+
* from the passed values, where a single number stands for both dimensions,
|
|
346
|
+
* as in `size.multiply(2)` and in radii.
|
|
347
|
+
*
|
|
348
|
+
* @param size
|
|
349
|
+
* @param height
|
|
350
|
+
*/
|
|
351
|
+
static coerce(size: SizeLike | number, height?: number): Size;
|
|
352
|
+
/**
|
|
353
|
+
* Returns a new size object with the smallest {@link #width} and
|
|
354
|
+
* {@link #height} of the supplied sizes.
|
|
355
|
+
*
|
|
356
|
+
* @param size1
|
|
357
|
+
* @param size2
|
|
358
|
+
* @return the newly created size object
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* var size1 = new Size(10, 100);
|
|
362
|
+
* var size2 = new Size(200, 5);
|
|
363
|
+
* var minSize = Size.min(size1, size2);
|
|
364
|
+
* console.log(minSize); // {width: 10, height: 5}
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* // Find the minimum of multiple sizes:
|
|
368
|
+
* var size1 = new Size(60, 100);
|
|
369
|
+
* var size2 = new Size(200, 5);
|
|
370
|
+
* var size3 = new Size(250, 35);
|
|
371
|
+
* [size1, size2, size3].reduce(Size.min) // {width: 60, height: 5}
|
|
372
|
+
*/
|
|
373
|
+
static min(size1: SizeLike, size2: SizeLike): Size;
|
|
374
|
+
/**
|
|
375
|
+
* Returns a new size object with the largest {@link #width} and
|
|
376
|
+
* {@link #height} of the supplied sizes.
|
|
377
|
+
*
|
|
378
|
+
* @param size1
|
|
379
|
+
* @param size2
|
|
380
|
+
* @return the newly created size object
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* var size1 = new Size(10, 100);
|
|
384
|
+
* var size2 = new Size(200, 5);
|
|
385
|
+
* var maxSize = Size.max(size1, size2);
|
|
386
|
+
* console.log(maxSize); // {width: 200, height: 100}
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* // Find the maximum of multiple sizes:
|
|
390
|
+
* var size1 = new Size(60, 100);
|
|
391
|
+
* var size2 = new Size(200, 5);
|
|
392
|
+
* var size3 = new Size(250, 35);
|
|
393
|
+
* [size1, size2, size3].reduce(Size.max) // {width: 250, height: 100}
|
|
394
|
+
*/
|
|
395
|
+
static max(size1: SizeLike, size2: SizeLike): Size;
|
|
396
|
+
/**
|
|
397
|
+
* Returns a size object with random {@link #width} and {@link #height}
|
|
398
|
+
* values between `0` and `1`.
|
|
399
|
+
*
|
|
400
|
+
* @return the newly created size object
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* var maxSize = new Size(100, 100);
|
|
404
|
+
* var randomSize = Size.random();
|
|
405
|
+
* var size = maxSize * randomSize;
|
|
406
|
+
*/
|
|
407
|
+
static random(): Size;
|
|
408
|
+
/**
|
|
409
|
+
* {@grouptitle Math Functions}
|
|
410
|
+
*
|
|
411
|
+
* Returns a new size with rounded {@link #width} and {@link #height}
|
|
412
|
+
* values. The object itself is not modified!
|
|
413
|
+
*
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* var size = new Size(10.2, 10.9);
|
|
417
|
+
* var roundSize = size.round();
|
|
418
|
+
* console.log(roundSize); // {x: 10, y: 11}
|
|
419
|
+
*/
|
|
420
|
+
round(): Size;
|
|
421
|
+
/**
|
|
422
|
+
* Returns a new size with the nearest greater non-fractional values to the
|
|
423
|
+
* specified {@link #width} and {@link #height} values. The object itself is
|
|
424
|
+
* not modified!
|
|
425
|
+
*
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* var size = new Size(10.2, 10.9);
|
|
429
|
+
* var ceilSize = size.ceil();
|
|
430
|
+
* console.log(ceilSize); // {x: 11, y: 11}
|
|
431
|
+
*/
|
|
432
|
+
ceil(): Size;
|
|
433
|
+
/**
|
|
434
|
+
* Returns a new size with the nearest smaller non-fractional values to the
|
|
435
|
+
* specified {@link #width} and {@link #height} values. The object itself is
|
|
436
|
+
* not modified!
|
|
437
|
+
*
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* var size = new Size(10.2, 10.9);
|
|
441
|
+
* var floorSize = size.floor();
|
|
442
|
+
* console.log(floorSize); // {x: 10, y: 10}
|
|
443
|
+
*/
|
|
444
|
+
floor(): Size;
|
|
445
|
+
/**
|
|
446
|
+
* Returns a new size with the absolute values of the specified
|
|
447
|
+
* {@link #width} and {@link #height} values. The object itself is not
|
|
448
|
+
* modified!
|
|
449
|
+
*
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* var size = new Size(-5, 10);
|
|
453
|
+
* var absSize = size.abs();
|
|
454
|
+
* console.log(absSize); // {x: 5, y: 10}
|
|
455
|
+
*/
|
|
456
|
+
abs(): Size;
|
|
457
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Point } from '../basic/Point.ts';
|
|
2
|
+
import type { CurveValues, PathValues, RegionValues, SegmentValues } from '../values/index.ts';
|
|
3
|
+
import type { FillRule } from '../values/region.ts';
|
|
4
|
+
export type TracedPath = {
|
|
5
|
+
segments: [number[], number[], number[]][];
|
|
6
|
+
sources: Source[];
|
|
7
|
+
};
|
|
8
|
+
export type Source = {
|
|
9
|
+
operand: number;
|
|
10
|
+
path: number;
|
|
11
|
+
curve: number;
|
|
12
|
+
time1: number;
|
|
13
|
+
time2: number;
|
|
14
|
+
};
|
|
15
|
+
export type Operator = (inside1: boolean, inside2: boolean) => boolean;
|
|
16
|
+
export type Operand = {
|
|
17
|
+
paths: PathValues[];
|
|
18
|
+
fillRule?: FillRule;
|
|
19
|
+
};
|
|
20
|
+
type Vertex = {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
isEnd: boolean;
|
|
24
|
+
point: number;
|
|
25
|
+
outgoing: number[];
|
|
26
|
+
};
|
|
27
|
+
export type Piece = {
|
|
28
|
+
curve: number;
|
|
29
|
+
edge: number;
|
|
30
|
+
time1: number;
|
|
31
|
+
time2: number;
|
|
32
|
+
values: CurveValues;
|
|
33
|
+
};
|
|
34
|
+
type Edge = {
|
|
35
|
+
values: CurveValues;
|
|
36
|
+
from: number;
|
|
37
|
+
to: number;
|
|
38
|
+
isStraight: boolean;
|
|
39
|
+
windings: number[];
|
|
40
|
+
curve: number;
|
|
41
|
+
time1: number;
|
|
42
|
+
time2: number;
|
|
43
|
+
reversed?: CurveValues;
|
|
44
|
+
length?: number;
|
|
45
|
+
};
|
|
46
|
+
type HalfEdge = {
|
|
47
|
+
edge: Edge;
|
|
48
|
+
values: CurveValues;
|
|
49
|
+
from: number;
|
|
50
|
+
to: number;
|
|
51
|
+
directions: {
|
|
52
|
+
start: number;
|
|
53
|
+
width: number;
|
|
54
|
+
} | null;
|
|
55
|
+
point: Point;
|
|
56
|
+
angle: number;
|
|
57
|
+
position: number;
|
|
58
|
+
next: number;
|
|
59
|
+
face: Face;
|
|
60
|
+
};
|
|
61
|
+
type Face = {
|
|
62
|
+
halfEdges: number[];
|
|
63
|
+
area: number;
|
|
64
|
+
windings: number[] | null;
|
|
65
|
+
component: Component | null;
|
|
66
|
+
isInside?: boolean;
|
|
67
|
+
};
|
|
68
|
+
type Component = {
|
|
69
|
+
edges: Edge[];
|
|
70
|
+
bounds: number[];
|
|
71
|
+
outside: Face;
|
|
72
|
+
};
|
|
73
|
+
type GraphCurve = {
|
|
74
|
+
next: GraphCurve | null;
|
|
75
|
+
previous: GraphCurve | null;
|
|
76
|
+
index: number;
|
|
77
|
+
operand: number;
|
|
78
|
+
path: number;
|
|
79
|
+
curve: number;
|
|
80
|
+
hasHandles: boolean;
|
|
81
|
+
};
|
|
82
|
+
export type Graph = {
|
|
83
|
+
curves: GraphCurve[];
|
|
84
|
+
values: CurveValues[];
|
|
85
|
+
pieces: Piece[][];
|
|
86
|
+
vertices: Vertex[];
|
|
87
|
+
edges: Edge[];
|
|
88
|
+
halfEdges: HalfEdge[];
|
|
89
|
+
faces: Face[];
|
|
90
|
+
nonZeros: boolean[];
|
|
91
|
+
epsilon: number;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Creates a planar graph of the operands' curves: All intersections become
|
|
95
|
+
* vertices, the pieces of curves between them edges, and the edges bound
|
|
96
|
+
* faces with a known winding for each operand.
|
|
97
|
+
*
|
|
98
|
+
* @param operands one or two operands
|
|
99
|
+
* @return the graph's vertices, edges, half-edges and faces
|
|
100
|
+
*/
|
|
101
|
+
export declare function createGraph(operands: Operand[]): Graph;
|
|
102
|
+
/**
|
|
103
|
+
* Traces the outlines of the areas that the operator includes, along the
|
|
104
|
+
* edges of the operands' graph that have the result on their left and not
|
|
105
|
+
* on their right. At each vertex, we turn through the result until the
|
|
106
|
+
* next of them, which keeps contours apart that only touch.
|
|
107
|
+
*
|
|
108
|
+
* @param operands one or two operands, with closed paths only
|
|
109
|
+
* @param operator decides if a face is part of the result, from
|
|
110
|
+
* whether it is inside each of the operands
|
|
111
|
+
* @return the traced paths
|
|
112
|
+
*/
|
|
113
|
+
export declare function traceGraph(operands: RegionValues[], operator: Operator): TracedPath[];
|
|
114
|
+
export declare function isFilled(graph: Graph, windings: number[], operand: number): boolean;
|
|
115
|
+
export declare function joinPieces(graph: Graph, pieces: Piece[]): {
|
|
116
|
+
segments: SegmentValues[];
|
|
117
|
+
parts: {
|
|
118
|
+
curve: number;
|
|
119
|
+
time1: number;
|
|
120
|
+
time2: number;
|
|
121
|
+
}[];
|
|
122
|
+
};
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createGraph, traceGraph } from './graph.ts';
|
|
2
|
+
import { splitGraph } from './split.ts';
|
|
3
|
+
import { combineBalanced, traceRegions } from './operations.ts';
|
|
4
|
+
import type { PathValues, RegionValues } from '../values/index.ts';
|
|
5
|
+
export { formatSVGPath, parseSVGPath } from '../values/index.ts';
|
|
6
|
+
export type { PathValues, RegionValues } from '../values/index.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Unites the regions.
|
|
9
|
+
*
|
|
10
|
+
* @param regions the regions to unite
|
|
11
|
+
* @return the region that they cover together
|
|
12
|
+
*/
|
|
13
|
+
export declare function unite(regions: RegionValues[]): RegionValues;
|
|
14
|
+
/**
|
|
15
|
+
* Subtracts the other regions from the region.
|
|
16
|
+
*
|
|
17
|
+
* @param region the region to subtract from
|
|
18
|
+
* @param others the region or regions to subtract
|
|
19
|
+
* @return the part of the region that the others don't cover
|
|
20
|
+
*/
|
|
21
|
+
export declare function subtract(region: RegionValues, others: RegionValues | RegionValues[]): RegionValues;
|
|
22
|
+
/**
|
|
23
|
+
* Intersects the region with the other regions.
|
|
24
|
+
*
|
|
25
|
+
* @param region the region to intersect
|
|
26
|
+
* @param others the region or regions to intersect it with
|
|
27
|
+
* @return the part of the region that all others cover
|
|
28
|
+
*/
|
|
29
|
+
export declare function intersect(region: RegionValues, others: RegionValues | RegionValues[]): RegionValues;
|
|
30
|
+
/**
|
|
31
|
+
* Excludes the other regions from the region, and the region from them.
|
|
32
|
+
*
|
|
33
|
+
* @param region the region to exclude
|
|
34
|
+
* @param others the region or regions to exclude it with
|
|
35
|
+
* @return the parts that either the region or the others cover, not both
|
|
36
|
+
*/
|
|
37
|
+
export declare function exclude(region: RegionValues, others: RegionValues | RegionValues[]): RegionValues;
|
|
38
|
+
/**
|
|
39
|
+
* Checks whether the region contains the point, which it also does on its
|
|
40
|
+
* outline.
|
|
41
|
+
*
|
|
42
|
+
* @param region the region to check
|
|
43
|
+
* @param point the point, as `[x, y]`
|
|
44
|
+
* @return true if the region contains the point
|
|
45
|
+
*/
|
|
46
|
+
export declare function contains(region: RegionValues, [x, y]: number[]): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Splits the paths where they cross the outline of the region. The pieces
|
|
49
|
+
* along the outline count as inside of it.
|
|
50
|
+
*
|
|
51
|
+
* @param paths the paths to split, open or closed
|
|
52
|
+
* @param region the region to split them by
|
|
53
|
+
* @return the pieces inside the region and outside of it, in their order
|
|
54
|
+
* along the paths
|
|
55
|
+
*/
|
|
56
|
+
export declare function split(paths: PathValues[], region: RegionValues): {
|
|
57
|
+
inside: PathValues[];
|
|
58
|
+
outside: PathValues[];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The boolean operations of path items, for `use(boolean)` with
|
|
62
|
+
* `paper/core`, see the `use()` function there.
|
|
63
|
+
*/
|
|
64
|
+
export declare const boolean: {
|
|
65
|
+
feature: {
|
|
66
|
+
name: "boolean";
|
|
67
|
+
booleanOperators: Record<"intersect" | "unite" | "subtract" | "exclude", import("./graph.ts").Operator>;
|
|
68
|
+
combineBalanced: typeof combineBalanced;
|
|
69
|
+
createGraph: typeof createGraph;
|
|
70
|
+
splitGraph: typeof splitGraph;
|
|
71
|
+
traceGraph: typeof traceGraph;
|
|
72
|
+
traceRegions: typeof traceRegions;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Rectangle } from '../basic/Rectangle.ts';
|
|
2
|
+
import type { Operator } from './graph.ts';
|
|
3
|
+
import type { RegionValues } from '../values/index.ts';
|
|
4
|
+
export declare const booleanOperators: Record<'unite' | 'intersect' | 'subtract' | 'exclude', Operator>;
|
|
5
|
+
export declare function uniteRegions(regions: RegionValues[]): RegionValues;
|
|
6
|
+
export declare function excludeRegions(regions: RegionValues[]): RegionValues;
|
|
7
|
+
export declare function combineBalanced<T>(values: T[], combine: (value1: T, value2: T) => T, getBounds?: (value: T) => Rectangle): T;
|
|
8
|
+
export declare function subtractRegions(region1: RegionValues, region2: RegionValues): RegionValues;
|
|
9
|
+
export declare function traceRegions(region1: RegionValues, region2: RegionValues | null, operator: Operator): RegionValues;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PathValues, RegionValues } from '../values/index.ts';
|
|
2
|
+
export type SplitPiece = PathValues & {
|
|
3
|
+
isInside: boolean;
|
|
4
|
+
source: number;
|
|
5
|
+
offset: number;
|
|
6
|
+
isWhole: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Splits the paths where they cross the outline of the region, into pieces
|
|
10
|
+
* inside of it and outside, in their order along the paths. The graph cuts
|
|
11
|
+
* the paths as it does for the boolean operations, so it decides as they do
|
|
12
|
+
* where paths touch the outline or run along it. The pieces along it count
|
|
13
|
+
* as inside, but are split from the pieces next to them.
|
|
14
|
+
*
|
|
15
|
+
* @param paths the paths to split, open or closed
|
|
16
|
+
* @param region the region to split them by
|
|
17
|
+
* @return the pieces of the paths
|
|
18
|
+
*/
|
|
19
|
+
export declare function splitGraph(paths: PathValues[], region: RegionValues): SplitPiece[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Point } from '../basic/Point.ts';
|
|
2
|
+
import type { Size } from '../basic/Size.ts';
|
|
3
|
+
export type BlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'soft-light' | 'hard-light' | 'color-dodge' | 'color-burn' | 'darken' | 'lighten' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'luminosity' | 'color' | 'add' | 'subtract' | 'average' | 'pin-light' | 'negation' | 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'darker' | 'copy' | 'xor';
|
|
4
|
+
/**
|
|
5
|
+
* The blend modes by name, `true` for those that canvas supports natively.
|
|
6
|
+
* Canvas supports its composite modes and the CSS blend modes, and draws modes
|
|
7
|
+
* it doesn't support as 'normal', so only our own modes are emulated.
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export declare const nativeBlendModes: Record<string, boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Composites the part of the source canvas that size covers onto the
|
|
14
|
+
* destination at the offset, with the blend mode and alpha.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
export declare function blend(mode: BlendMode, srcContext: CanvasRenderingContext2D, dstContext: CanvasRenderingContext2D, alpha: number, offset: Point, size: Size): void;
|