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,383 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
3
|
+
* http://paperjs.org/
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2011 - 2026, Jürg Lehni & Jonathan Puckey
|
|
6
|
+
* http://juerglehni.com/ & https://puckey.studio/
|
|
7
|
+
*
|
|
8
|
+
* Distributed under the MIT license. See LICENSE file for details.
|
|
9
|
+
*
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
*/
|
|
12
|
+
import { Change, ChangeFlag, EPSILON, GEOMETRIC_EPSILON, Group, ItemDefinition, Matrix, Point, Rectangle, Size, drawItem, equals, getCanvas, getWindow, registerClasses, serialize } from "../internal.js";
|
|
13
|
+
// The resolutions per octave of scale that the tiles are drawn at:
|
|
14
|
+
const levelsPerOctave = 4;
|
|
15
|
+
// The largest denominator of the fractions that shifts are taken to:
|
|
16
|
+
const maxDenominator = 24;
|
|
17
|
+
/**
|
|
18
|
+
* A pattern definition repeats an item as the tile of pattern colors, which
|
|
19
|
+
* fill and stroke items with it, see {@link Color#pattern}: a {@link Raster}
|
|
20
|
+
* for image patterns, or any other item for vector patterns. As with symbol
|
|
21
|
+
* definitions, the item is removed from the scene graph, and all pattern
|
|
22
|
+
* colors that use the pattern share it, so they change along with it.
|
|
23
|
+
*
|
|
24
|
+
* @classexample {@paperscript height=200}
|
|
25
|
+
* // A dotted pattern, filling and stroking a circle:
|
|
26
|
+
* var dot = Path.circle({
|
|
27
|
+
* center: [5, 5],
|
|
28
|
+
* radius: 3,
|
|
29
|
+
* fillColor: 'red'
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Repeat the dot every 10 points, and every 12 points in the stroke's
|
|
33
|
+
* // pattern, with 2 points of spacing:
|
|
34
|
+
* var pattern = new PatternDefinition(dot, {
|
|
35
|
+
* size: [10, 10]
|
|
36
|
+
* });
|
|
37
|
+
* var spaced = new PatternDefinition(dot.clone(), {
|
|
38
|
+
* size: [10, 10],
|
|
39
|
+
* spacing: 2
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* var circle = Path.circle({
|
|
43
|
+
* center: view.center,
|
|
44
|
+
* radius: 70,
|
|
45
|
+
* fillColor: { pattern: pattern },
|
|
46
|
+
* strokeColor: {
|
|
47
|
+
* pattern: spaced,
|
|
48
|
+
* matrix: new Matrix().rotate(45)
|
|
49
|
+
* },
|
|
50
|
+
* strokeWidth: 20
|
|
51
|
+
* });
|
|
52
|
+
*/
|
|
53
|
+
export class PatternDefinition extends ItemDefinition {
|
|
54
|
+
static {
|
|
55
|
+
registerClasses({ PatternDefinition: this });
|
|
56
|
+
}
|
|
57
|
+
#size = null;
|
|
58
|
+
#spacing = null;
|
|
59
|
+
#pitch = new Size(1, 1);
|
|
60
|
+
#shift = new Point();
|
|
61
|
+
#rightInFront = false;
|
|
62
|
+
#bottomInFront = false;
|
|
63
|
+
#canvases = {};
|
|
64
|
+
/**
|
|
65
|
+
* Creates a pattern definition.
|
|
66
|
+
*
|
|
67
|
+
* @param item the item to repeat, which is removed from the scene graph and
|
|
68
|
+
* becomes the pattern's tile content
|
|
69
|
+
* @param options the tiles, their arrangement and the name of the pattern
|
|
70
|
+
* @option [options.size] {Size} the size of the tiles without their spacing,
|
|
71
|
+
* that of the item's bounds by default
|
|
72
|
+
* @option [options.spacing] {Size} the gap between the tiles
|
|
73
|
+
* @option [options.pitch=[1, 1]] {Size} the distance between the columns and
|
|
74
|
+
* between the rows, in tiles
|
|
75
|
+
* @option [options.shift=[0, 0]] {Point} the shift of each row or of each
|
|
76
|
+
* column, in tiles
|
|
77
|
+
* @option [options.rightInFront=false] {Boolean} whether the tiles on the
|
|
78
|
+
* right lie over those on their left
|
|
79
|
+
* @option [options.bottomInFront=false] {Boolean} whether the rows lie over
|
|
80
|
+
* the rows above them
|
|
81
|
+
* @option [options.name] {String} the name of the pattern
|
|
82
|
+
*/
|
|
83
|
+
constructor(item, options) {
|
|
84
|
+
super();
|
|
85
|
+
if (item) {
|
|
86
|
+
this._setItem(item);
|
|
87
|
+
}
|
|
88
|
+
if (options) {
|
|
89
|
+
this.set(options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// @override
|
|
93
|
+
_serializeDefinition(options, dictionary) {
|
|
94
|
+
return dictionary.add(this, () => {
|
|
95
|
+
const json = [this._item];
|
|
96
|
+
// Leave out the options that are the defaults:
|
|
97
|
+
const defaults = new PatternDefinition()._getOptions();
|
|
98
|
+
const props = Object.fromEntries(Object.entries(this._getOptions()).filter(([key, value]) => !equals(value, defaults[key])));
|
|
99
|
+
if (this._name) {
|
|
100
|
+
props.name = this._name;
|
|
101
|
+
}
|
|
102
|
+
if (Object.keys(props).length) {
|
|
103
|
+
json.push(props);
|
|
104
|
+
}
|
|
105
|
+
return serialize(json, options, false, dictionary);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// Returns the options of the pattern's tiles, as its constructor takes them:
|
|
109
|
+
_getOptions() {
|
|
110
|
+
return {
|
|
111
|
+
size: this.#size,
|
|
112
|
+
spacing: this.#spacing,
|
|
113
|
+
pitch: this.#pitch,
|
|
114
|
+
shift: this.#shift,
|
|
115
|
+
rightInFront: this.#rightInFront,
|
|
116
|
+
bottomInFront: this.#bottomInFront
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
_changed(flags) {
|
|
120
|
+
super._changed(flags);
|
|
121
|
+
// Draw the tiles again at each resolution that they're needed in:
|
|
122
|
+
if (flags & ChangeFlag.APPEARANCE) {
|
|
123
|
+
this.#canvases = {};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The size of the tiles, without their {@link #spacing}. The item isn't
|
|
128
|
+
* clipped by its tile: parts that reach beyond it lie over the tiles around
|
|
129
|
+
* it, see {@link #rightInFront} and {@link #bottomInFront}.
|
|
130
|
+
*
|
|
131
|
+
* @default the size of the bounds of the pattern's item
|
|
132
|
+
*/
|
|
133
|
+
get size() {
|
|
134
|
+
return this.#size ?? this._item.bounds.size;
|
|
135
|
+
}
|
|
136
|
+
set size(size) {
|
|
137
|
+
this.#size = size == null ? null : new Size(size);
|
|
138
|
+
this._changed(Change.STYLE);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The gap between the tiles, horizontally and vertically, e.g. to leave
|
|
142
|
+
* space around the item while the tiles follow its size. Negative values
|
|
143
|
+
* move the tiles into each other.
|
|
144
|
+
*
|
|
145
|
+
* @default null
|
|
146
|
+
*/
|
|
147
|
+
get spacing() {
|
|
148
|
+
return this.#spacing;
|
|
149
|
+
}
|
|
150
|
+
set spacing(spacing) {
|
|
151
|
+
this.#spacing = spacing == null ? null : new Size(spacing);
|
|
152
|
+
this._changed(Change.STYLE);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The distance between the columns and between the rows of tiles, in tiles
|
|
156
|
+
* with their spacing, e.g. `[0.75, 1]` for the columns of hexagons, which
|
|
157
|
+
* lie a quarter into each other.
|
|
158
|
+
*
|
|
159
|
+
* @default [1, 1]
|
|
160
|
+
*/
|
|
161
|
+
get pitch() {
|
|
162
|
+
return this.#pitch;
|
|
163
|
+
}
|
|
164
|
+
set pitch(pitch) {
|
|
165
|
+
this.#pitch = new Size(pitch);
|
|
166
|
+
this._changed(Change.STYLE);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The shift of each row of tiles against the row above it, as `x`, or of
|
|
170
|
+
* each column against the column to its left, as `y`, in tiles with their
|
|
171
|
+
* spacing, e.g. `[0.5, 0]` for the rows of a brick wall, and `[0, 0.5]`
|
|
172
|
+
* for the columns of hexagons. Only rows or columns can be shifted, not
|
|
173
|
+
* both. Shifts are taken to the closest fractions of the distance between
|
|
174
|
+
* the columns or rows, with denominators of up to 24.
|
|
175
|
+
*
|
|
176
|
+
* @default [0, 0]
|
|
177
|
+
*/
|
|
178
|
+
get shift() {
|
|
179
|
+
return this.#shift;
|
|
180
|
+
}
|
|
181
|
+
set shift(shift) {
|
|
182
|
+
const point = new Point(shift);
|
|
183
|
+
if (point.x && point.y) {
|
|
184
|
+
throw new Error(`Invalid shift: '${point}', rows and columns can't both be shifted.`);
|
|
185
|
+
}
|
|
186
|
+
this.#shift = point;
|
|
187
|
+
this._changed(Change.STYLE);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Specifies whether the tiles on the right lie over the tiles on their left
|
|
191
|
+
* where the item reaches beyond its tile, or below them. Tiles are drawn row
|
|
192
|
+
* by row, and the tiles that columns shift down by less than a row, as
|
|
193
|
+
* hexagons do, stay in the row of their height.
|
|
194
|
+
*
|
|
195
|
+
* @default false
|
|
196
|
+
*/
|
|
197
|
+
get rightInFront() {
|
|
198
|
+
return this.#rightInFront;
|
|
199
|
+
}
|
|
200
|
+
set rightInFront(rightInFront) {
|
|
201
|
+
this.#rightInFront = rightInFront;
|
|
202
|
+
this._changed(Change.STYLE);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Specifies whether the rows of tiles lie over the rows above them where
|
|
206
|
+
* the item reaches beyond its tile, or below them, see
|
|
207
|
+
* {@link #rightInFront}.
|
|
208
|
+
*
|
|
209
|
+
* @default false
|
|
210
|
+
*/
|
|
211
|
+
get bottomInFront() {
|
|
212
|
+
return this.#bottomInFront;
|
|
213
|
+
}
|
|
214
|
+
set bottomInFront(bottomInFront) {
|
|
215
|
+
this.#bottomInFront = bottomInFront;
|
|
216
|
+
this._changed(Change.STYLE);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Returns a copy of the pattern, with a copy of its item and its name.
|
|
220
|
+
*/
|
|
221
|
+
clone() {
|
|
222
|
+
return new PatternDefinition(this._item.clone(false), {
|
|
223
|
+
...this._getOptions(),
|
|
224
|
+
name: this._name
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Checks whether the pattern is equal to the supplied pattern.
|
|
229
|
+
*
|
|
230
|
+
* @param pattern the pattern to compare with
|
|
231
|
+
* @return {@true if they are equal}
|
|
232
|
+
*/
|
|
233
|
+
equals(pattern) {
|
|
234
|
+
return (pattern === this || (pattern instanceof PatternDefinition &&
|
|
235
|
+
this._item.equals(pattern._item) &&
|
|
236
|
+
equals(this._getOptions(), pattern._getOptions())));
|
|
237
|
+
}
|
|
238
|
+
// Returns a CanvasPattern of the tiles, placed through the matrix from the
|
|
239
|
+
// pattern's coordinates to those of the context. The tiles are drawn at
|
|
240
|
+
// the context's resolution, rounded up to quarter octaves, so that items
|
|
241
|
+
// at nearby scales share them. See Color#toCanvasStyle():
|
|
242
|
+
_toCanvasStyle(ctx, matrix) {
|
|
243
|
+
const transform = ctx.getTransform();
|
|
244
|
+
const device = new Matrix(transform.a, transform.b, transform.c, transform.d, 0, 0).append(matrix);
|
|
245
|
+
const scale = Math.max(Math.sqrt(device.a * device.a + device.b * device.b), Math.sqrt(device.c * device.c + device.d * device.d));
|
|
246
|
+
const level = Math.ceil(Math.log(scale) / Math.LN2 * levelsPerOctave - EPSILON);
|
|
247
|
+
const repeat = this._getRepeat();
|
|
248
|
+
if (!repeat) {
|
|
249
|
+
return 'rgba(0,0,0,0)';
|
|
250
|
+
}
|
|
251
|
+
const { bounds } = repeat;
|
|
252
|
+
const size = bounds.size
|
|
253
|
+
.multiply(Math.pow(2, level / levelsPerOctave))
|
|
254
|
+
.ceil();
|
|
255
|
+
let canvas = this.#canvases[level];
|
|
256
|
+
if (!canvas) {
|
|
257
|
+
// The tiles are kept for as long as the pattern doesn't change, so
|
|
258
|
+
// they're never released to the canvas provider's pool, as with the
|
|
259
|
+
// buffers of groups, see Item#draw():
|
|
260
|
+
const OffscreenCanvas = getWindow()?.OffscreenCanvas;
|
|
261
|
+
canvas = this.#canvases[level] = OffscreenCanvas
|
|
262
|
+
? new OffscreenCanvas(size.width, size.height)
|
|
263
|
+
: getCanvas(size);
|
|
264
|
+
const tileCtx = canvas.getContext('2d');
|
|
265
|
+
const tileMatrix = new Matrix()
|
|
266
|
+
.scale(size.divide(bounds.size))
|
|
267
|
+
.translate(bounds.point.negate());
|
|
268
|
+
for (const offset of this._getOffsets(bounds)) {
|
|
269
|
+
const matrix = tileMatrix.appended(new Matrix().translate(offset));
|
|
270
|
+
tileCtx.save();
|
|
271
|
+
matrix.applyToContext(tileCtx);
|
|
272
|
+
// The item is shared by all colors of the pattern, so don't let them
|
|
273
|
+
// set its global matrix, as in SymbolItem#_draw():
|
|
274
|
+
drawItem(this._item, tileCtx, {
|
|
275
|
+
matrices: [matrix],
|
|
276
|
+
updateMatrix: false
|
|
277
|
+
});
|
|
278
|
+
tileCtx.restore();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// The canvas isn't empty, see above:
|
|
282
|
+
const pattern = ctx.createPattern(canvas, 'repeat');
|
|
283
|
+
const placement = matrix.appended(new Matrix().translate(bounds.point).scale(bounds.size.divide(size)));
|
|
284
|
+
// Reuse the context's DOMMatrix, as node-canvas only takes its own:
|
|
285
|
+
transform.a = placement.a;
|
|
286
|
+
transform.b = placement.b;
|
|
287
|
+
transform.c = placement.c;
|
|
288
|
+
transform.d = placement.d;
|
|
289
|
+
transform.e = placement.tx;
|
|
290
|
+
transform.f = placement.ty;
|
|
291
|
+
pattern.setTransform(transform);
|
|
292
|
+
return pattern;
|
|
293
|
+
}
|
|
294
|
+
// Returns the rectangle that the pattern repeats in as a whole, and the
|
|
295
|
+
// matrix that places the tiles of the columns and rows in it. Patterns whose
|
|
296
|
+
// tiles have no area have none:
|
|
297
|
+
_getRepeat() {
|
|
298
|
+
const { size, spacing } = this;
|
|
299
|
+
const tile = spacing ? size.add(spacing) : size;
|
|
300
|
+
const { width, height } = tile.multiply(this.#pitch);
|
|
301
|
+
if (!(width > 0 && height > 0)) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
// A shift by a fraction repeats after as many rows or columns as its
|
|
305
|
+
// denominator:
|
|
306
|
+
const [rowShift, rows] = getFraction(this.#shift.x / this.#pitch.width);
|
|
307
|
+
const [columnShift, columns] = getFraction(this.#shift.y / this.#pitch.height);
|
|
308
|
+
return {
|
|
309
|
+
bounds: new Rectangle(0, 0, width * columns, height * rows),
|
|
310
|
+
matrix: new Matrix(width, height * columnShift / columns, width * rowShift / rows, height, 0, 0)
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
// Returns the offsets of the tiles whose items reach into the rectangle with
|
|
314
|
+
// what they draw, in the order in which they are drawn, see #rightInFront.
|
|
315
|
+
_getOffsets(rect) {
|
|
316
|
+
const offsets = [];
|
|
317
|
+
const repeat = this._getRepeat();
|
|
318
|
+
const bounds = this._item.previewBounds;
|
|
319
|
+
if (repeat && !bounds.isEmpty()) {
|
|
320
|
+
const { matrix } = repeat;
|
|
321
|
+
// The offsets at which the item reaches into the rectangle, and the
|
|
322
|
+
// columns and rows of the tiles that may lie there:
|
|
323
|
+
const area = new Rectangle(rect.topLeft.subtract(bounds.bottomRight).add(GEOMETRIC_EPSILON), rect.bottomRight.subtract(bounds.topLeft).subtract(GEOMETRIC_EPSILON));
|
|
324
|
+
const range = matrix.inverted()._transformBounds(area);
|
|
325
|
+
const { floor, ceil } = Math;
|
|
326
|
+
for (let y = floor(range.top); y <= ceil(range.bottom); y++) {
|
|
327
|
+
for (let x = floor(range.left); x <= ceil(range.right); x++) {
|
|
328
|
+
const offset = matrix._transformPoint(new Point(x, y));
|
|
329
|
+
if (area.contains(offset)) {
|
|
330
|
+
offsets.push(offset);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// Draw row by row, with the tiles that shifted columns move down by less
|
|
335
|
+
// than a row in the row of their height, and the ones in front last:
|
|
336
|
+
const getRow = (offset) => floor(offset.y / matrix.d + GEOMETRIC_EPSILON);
|
|
337
|
+
const rowOrder = this.#bottomInFront ? 1 : -1;
|
|
338
|
+
const columnOrder = this.#rightInFront ? 1 : -1;
|
|
339
|
+
offsets.sort((a, b) => ((getRow(a) - getRow(b)) * rowOrder || (a.x - b.x) * columnOrder));
|
|
340
|
+
}
|
|
341
|
+
return offsets;
|
|
342
|
+
}
|
|
343
|
+
// Returns copies of the item as the tiles that cover the bounds, placed
|
|
344
|
+
// through the matrix as a pattern color places them, see Item#expand():
|
|
345
|
+
_getTiles(bounds, matrix) {
|
|
346
|
+
const inverse = matrix.inverted();
|
|
347
|
+
const tiles = new Group({ insert: false });
|
|
348
|
+
// Patterns that are drawn as nothing expand to nothing:
|
|
349
|
+
if (inverse) {
|
|
350
|
+
for (const offset of this._getOffsets(inverse._transformBounds(bounds))) {
|
|
351
|
+
tiles.addChild(this._item.clone(false).translate(offset));
|
|
352
|
+
}
|
|
353
|
+
tiles.transform(matrix);
|
|
354
|
+
}
|
|
355
|
+
return tiles;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Returns the passed pattern if it is one already, or else a new pattern
|
|
359
|
+
* that repeats the passed item.
|
|
360
|
+
*
|
|
361
|
+
* @param pattern the pattern, or the item to repeat
|
|
362
|
+
*/
|
|
363
|
+
static from(pattern) {
|
|
364
|
+
return pattern instanceof PatternDefinition
|
|
365
|
+
? pattern
|
|
366
|
+
: new PatternDefinition(pattern);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// Returns the closest fraction to the value, with a denominator of up to
|
|
370
|
+
// maxDenominator, as its numerator and denominator:
|
|
371
|
+
function getFraction(value) {
|
|
372
|
+
let fraction = [0, 1];
|
|
373
|
+
let closest = Infinity;
|
|
374
|
+
for (let denominator = 1; denominator <= maxDenominator; denominator++) {
|
|
375
|
+
const numerator = Math.round(value * denominator);
|
|
376
|
+
const distance = Math.abs(value - numerator / denominator);
|
|
377
|
+
if (distance < closest - EPSILON) {
|
|
378
|
+
fraction = [numerator, denominator];
|
|
379
|
+
closest = distance;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return fraction;
|
|
383
|
+
}
|