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,431 @@
|
|
|
1
|
+
import { Color, HitResult, Item, Matrix, PathItem, Point, Rectangle, Size } from '../internal.ts';
|
|
2
|
+
import type { Handler } from './Item.ts';
|
|
3
|
+
import type { ItemProps } from './props.ts';
|
|
4
|
+
import type { PointLike } from '../basic/Point.ts';
|
|
5
|
+
import type { SizeLike } from '../basic/Size.ts';
|
|
6
|
+
import type { RectangleLike } from '../basic/Rectangle.ts';
|
|
7
|
+
import type { ColorLike } from '../style/Color.ts';
|
|
8
|
+
import type { Project } from './Project.ts';
|
|
9
|
+
import type { DrawParam } from './draw.ts';
|
|
10
|
+
export type RasterSmoothing = 'low' | 'medium' | 'high' | 'off';
|
|
11
|
+
type Image = HTMLImageElement | HTMLCanvasElement;
|
|
12
|
+
/**
|
|
13
|
+
* The Raster item represents an image in a Paper.js project.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Raster extends Item {
|
|
16
|
+
_smoothing: RasterSmoothing;
|
|
17
|
+
_size: Size;
|
|
18
|
+
_loaded: boolean;
|
|
19
|
+
_image: HTMLImageElement | null;
|
|
20
|
+
_canvas: HTMLCanvasElement | null;
|
|
21
|
+
_context: CanvasRenderingContext2D | null;
|
|
22
|
+
_crossOrigin: string;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new raster item from the passed argument, and places it in the
|
|
25
|
+
* active layer. `source` can either be a DOM Image, a Canvas, or a string
|
|
26
|
+
* describing the URL to load the image from, or the ID of a DOM element to
|
|
27
|
+
* get the image from (either a DOM Image or a Canvas).
|
|
28
|
+
*
|
|
29
|
+
* @param [source] the source of the raster
|
|
30
|
+
* @param [position] the center position at which the raster item is
|
|
31
|
+
* placed
|
|
32
|
+
*
|
|
33
|
+
* @example {@paperscript height=300} // Creating a raster using a url
|
|
34
|
+
* var url = 'http://assets.paperjs.org/images/marilyn.jpg';
|
|
35
|
+
* var raster = new Raster(url);
|
|
36
|
+
*
|
|
37
|
+
* // If you create a Raster using a url, you can use the onLoad
|
|
38
|
+
* // handler to do something once it is loaded:
|
|
39
|
+
* raster.onLoad = function() {
|
|
40
|
+
* console.log('The image has loaded.');
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* @example // Creating a raster using the id of a DOM Image:
|
|
44
|
+
*
|
|
45
|
+
* // Create a raster using the id of the image:
|
|
46
|
+
* var raster = new Raster('art');
|
|
47
|
+
*
|
|
48
|
+
* @example // Creating a raster using a DOM Image:
|
|
49
|
+
*
|
|
50
|
+
* // Find the element using its id:
|
|
51
|
+
* var imageElement = document.getElementById('art');
|
|
52
|
+
*
|
|
53
|
+
* // Create the raster:
|
|
54
|
+
* var raster = new Raster(imageElement);
|
|
55
|
+
*/
|
|
56
|
+
constructor(source?: Image | string, position?: PointLike);
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new empty raster of the given size, and places it in the
|
|
59
|
+
* active layer.
|
|
60
|
+
*
|
|
61
|
+
* @param size the size of the raster
|
|
62
|
+
* @param [position] the center position at which the raster item is
|
|
63
|
+
* placed
|
|
64
|
+
*
|
|
65
|
+
* @example {@paperscript height=150}
|
|
66
|
+
* // Creating an empty raster and fill it with random pixels:
|
|
67
|
+
* var width = 100;
|
|
68
|
+
* var height = 100;
|
|
69
|
+
*
|
|
70
|
+
* // Create an empty raster placed at view center.
|
|
71
|
+
* var raster = new Raster(new Size(width, height), view.center);
|
|
72
|
+
*
|
|
73
|
+
* // For all of its pixels...
|
|
74
|
+
* for (var i = 0; i < width; i++) {
|
|
75
|
+
* for (var j = 0; j < height; j++) {
|
|
76
|
+
* // ...set a random color.
|
|
77
|
+
* raster.setPixel(i, j, Color.random());
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
*/
|
|
81
|
+
constructor(size: SizeLike, position?: PointLike);
|
|
82
|
+
/**
|
|
83
|
+
* Creates a new raster from an object description, and places it in the
|
|
84
|
+
* active layer.
|
|
85
|
+
*
|
|
86
|
+
* @param object an object containing properties to be set on the raster
|
|
87
|
+
*
|
|
88
|
+
* @example {@paperscript height=300}
|
|
89
|
+
* var raster = new Raster({
|
|
90
|
+
* source: 'http://assets.paperjs.org/images/marilyn.jpg',
|
|
91
|
+
* position: view.center
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* raster.scale(0.5);
|
|
95
|
+
* raster.rotate(10);
|
|
96
|
+
*/
|
|
97
|
+
constructor(object: ItemProps<Raster>);
|
|
98
|
+
_initializeContent(project: Project): void;
|
|
99
|
+
_equals(item: Item): boolean;
|
|
100
|
+
copyContent(source: this): void;
|
|
101
|
+
/**
|
|
102
|
+
* The size of the raster in pixels.
|
|
103
|
+
*/
|
|
104
|
+
get size(): Size;
|
|
105
|
+
set size(size: SizeLike);
|
|
106
|
+
_setSize(value: SizeLike, _clear?: boolean): void;
|
|
107
|
+
/**
|
|
108
|
+
* The width of the raster in pixels.
|
|
109
|
+
*/
|
|
110
|
+
get width(): number;
|
|
111
|
+
set width(width: number);
|
|
112
|
+
/**
|
|
113
|
+
* The height of the raster in pixels.
|
|
114
|
+
*/
|
|
115
|
+
get height(): number;
|
|
116
|
+
set height(height: number);
|
|
117
|
+
/**
|
|
118
|
+
* The loading state of the raster image.
|
|
119
|
+
*/
|
|
120
|
+
get loaded(): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Returns a promise that resolves with the raster once its image has
|
|
123
|
+
* loaded, at once if it has already or if the raster has no image to load,
|
|
124
|
+
* and that rejects if the image fails to load.
|
|
125
|
+
*
|
|
126
|
+
* @return a promise of the raster with its image loaded
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* var raster = new Raster('http://assets.paperjs.org/images/marilyn.jpg');
|
|
130
|
+
* raster.load().then(function() {
|
|
131
|
+
* console.log(raster.size);
|
|
132
|
+
* });
|
|
133
|
+
*/
|
|
134
|
+
load(): Promise<this>;
|
|
135
|
+
/**
|
|
136
|
+
* Creates a raster from the source and returns a promise that resolves
|
|
137
|
+
* with it once its image has loaded, see {@link #load()}.
|
|
138
|
+
*
|
|
139
|
+
* @param source the source of the raster, see the constructor
|
|
140
|
+
* @param [position] the center position at which the raster item is
|
|
141
|
+
* placed
|
|
142
|
+
* @return a promise of the raster with its image loaded
|
|
143
|
+
*/
|
|
144
|
+
static load(source: Image | string, position?: PointLike): Promise<Raster>;
|
|
145
|
+
isEmpty(): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* The resolution of the raster at its current size, in PPI (pixels per
|
|
148
|
+
* inch).
|
|
149
|
+
*/
|
|
150
|
+
get resolution(): Size;
|
|
151
|
+
/**
|
|
152
|
+
* The HTMLImageElement or Canvas element of the raster, if one is
|
|
153
|
+
* associated.
|
|
154
|
+
* Note that for consistency, an {@link #onLoad} event will be triggered on
|
|
155
|
+
* the raster even if the image has already finished loading before, or if
|
|
156
|
+
* we are setting the raster to a canvas.
|
|
157
|
+
*/
|
|
158
|
+
get image(): Image | null;
|
|
159
|
+
set image(image: Image);
|
|
160
|
+
set(props: ItemProps<this>, exclude?: Record<string, boolean>): this;
|
|
161
|
+
/**
|
|
162
|
+
* Internal version of {@link #image} that does not trigger events. This is
|
|
163
|
+
* used by #image, but also in other places where underlying canvases are
|
|
164
|
+
* replaced, resized, etc.
|
|
165
|
+
*/
|
|
166
|
+
_setImage(image: any): void;
|
|
167
|
+
/**
|
|
168
|
+
* The Canvas object of the raster. If the raster was created from an image,
|
|
169
|
+
* accessing its canvas causes the raster to try and create one and draw the
|
|
170
|
+
* image into it. Depending on security policies, this might fail, in which
|
|
171
|
+
* case `null` is returned instead.
|
|
172
|
+
*/
|
|
173
|
+
get canvas(): HTMLCanvasElement | null;
|
|
174
|
+
set canvas(canvas: HTMLCanvasElement);
|
|
175
|
+
/**
|
|
176
|
+
* The Canvas 2D drawing context of the raster.
|
|
177
|
+
*/
|
|
178
|
+
get context(): CanvasRenderingContext2D;
|
|
179
|
+
set context(context: CanvasRenderingContext2D);
|
|
180
|
+
_getContext(_change?: boolean): CanvasRenderingContext2D;
|
|
181
|
+
/**
|
|
182
|
+
* The source of the raster, which can be set using a string describing the
|
|
183
|
+
* URL to load the image from, or a data url. Reading this property will
|
|
184
|
+
* return the url of the source image or a data-url.
|
|
185
|
+
* To set the raster to a DOM Image or a Canvas, use {@link #image} or
|
|
186
|
+
* {@link #canvas} instead. The ID of a DOM Image or Canvas element is only
|
|
187
|
+
* accepted by the constructor.
|
|
188
|
+
* Note that for consistency, an {@link #onLoad} event will be triggered on
|
|
189
|
+
* the raster even if the image has already finished loading before.
|
|
190
|
+
*
|
|
191
|
+
* @example {@paperscript}
|
|
192
|
+
* var raster = new Raster();
|
|
193
|
+
* raster.source = 'http://paperjs.org/about/paper-js.gif';
|
|
194
|
+
* raster.position = view.center;
|
|
195
|
+
*
|
|
196
|
+
* @example {@paperscript}
|
|
197
|
+
* var raster = new Raster({
|
|
198
|
+
* source: 'http://paperjs.org/about/paper-js.gif',
|
|
199
|
+
* position: view.center
|
|
200
|
+
* });
|
|
201
|
+
*/
|
|
202
|
+
get source(): string | null;
|
|
203
|
+
set source(source: string);
|
|
204
|
+
/**
|
|
205
|
+
* The crossOrigin value to be used when loading the image resource, in
|
|
206
|
+
* order to support CORS. Note that this needs to be set before setting the
|
|
207
|
+
* {@link #source} property in order to always work (e.g. when the image is
|
|
208
|
+
* cached in the browser).
|
|
209
|
+
*
|
|
210
|
+
* @example {@paperscript}
|
|
211
|
+
* var raster = new Raster({
|
|
212
|
+
* crossOrigin: 'anonymous',
|
|
213
|
+
* source: 'http://assets.paperjs.org/images/marilyn.jpg',
|
|
214
|
+
* position: view.center
|
|
215
|
+
* });
|
|
216
|
+
*
|
|
217
|
+
* console.log(view.element.toDataURL('image/png').substring(0, 32));
|
|
218
|
+
*/
|
|
219
|
+
get crossOrigin(): string;
|
|
220
|
+
set crossOrigin(crossOrigin: string);
|
|
221
|
+
/**
|
|
222
|
+
* Determines if the raster is drawn with pixel smoothing when scaled up or
|
|
223
|
+
* down, and if so, at which quality its pixels are to be smoothed. The
|
|
224
|
+
* settings of this property control both the `imageSmoothingEnabled` and
|
|
225
|
+
* `imageSmoothingQuality` properties of the `CanvasRenderingContext2D`
|
|
226
|
+
* interface.
|
|
227
|
+
*
|
|
228
|
+
* By default, smoothing is enabled at `'low'` quality. It can be set to
|
|
229
|
+
* `'off'` to scale the raster's pixels by repeating the nearest neighboring
|
|
230
|
+
* pixels, or to `'low'`, `'medium'` or `'high'` to control the various
|
|
231
|
+
* degrees of available image smoothing quality.
|
|
232
|
+
*
|
|
233
|
+
* For backward compatibility, it can also be set to `false` (= `'off'`)
|
|
234
|
+
* or `true` (= `'low'`).
|
|
235
|
+
*
|
|
236
|
+
* @default 'low'
|
|
237
|
+
* @values 'low', 'medium', 'high', 'off'
|
|
238
|
+
*
|
|
239
|
+
* @example {@paperscript} var raster = new Raster({source:
|
|
240
|
+
* 'http://assets.paperjs.org/images/marilyn.jpg', smoothing: 'off'
|
|
241
|
+
* });
|
|
242
|
+
* raster.scale(5);
|
|
243
|
+
*/
|
|
244
|
+
get smoothing(): RasterSmoothing;
|
|
245
|
+
set smoothing(smoothing: RasterSmoothing | boolean);
|
|
246
|
+
/**
|
|
247
|
+
* The image or canvas that holds the pixels of the raster, once they are
|
|
248
|
+
* loaded, or `null` until then.
|
|
249
|
+
*/
|
|
250
|
+
get element(): Image | null;
|
|
251
|
+
/**
|
|
252
|
+
* Extracts a part of the Raster's content as a sub image, and returns it as
|
|
253
|
+
* a Canvas object.
|
|
254
|
+
*
|
|
255
|
+
* @param rect the boundaries of the sub image in pixel coordinates
|
|
256
|
+
*
|
|
257
|
+
* @return the sub image as a Canvas object
|
|
258
|
+
*/
|
|
259
|
+
getSubCanvas(rect: RectangleLike): HTMLCanvasElement;
|
|
260
|
+
/**
|
|
261
|
+
* Extracts a part of the raster item's content as a new raster item, placed
|
|
262
|
+
* in exactly the same place as the original content.
|
|
263
|
+
*
|
|
264
|
+
* @param rect the boundaries of the sub raster in pixel coordinates
|
|
265
|
+
*
|
|
266
|
+
* @return the sub raster as a newly created raster item
|
|
267
|
+
*/
|
|
268
|
+
getSubRaster(rect: RectangleLike): Raster;
|
|
269
|
+
/**
|
|
270
|
+
* Returns a Base 64 encoded `data:` URL representation of the raster.
|
|
271
|
+
* If the raster shows an image that was loaded from a `data:` URL, that
|
|
272
|
+
* URL is returned unchanged. Otherwise, the arguments are passed on to
|
|
273
|
+
* `HTMLCanvasElement#toDataURL()` of the raster's {@link #canvas}.
|
|
274
|
+
* In web-workers, where the canvas is an `OffscreenCanvas`, this is not
|
|
275
|
+
* supported, and neither are {@link #source} and exporting the raster to
|
|
276
|
+
* JSON, which rely on it. Use the canvas' asynchronous `convertToBlob()`
|
|
277
|
+
* there instead.
|
|
278
|
+
*
|
|
279
|
+
* @param [type='image/png'] the image format to encode
|
|
280
|
+
* @param [quality] the image quality between `0` and `1`, for formats that
|
|
281
|
+
* use lossy compression, such as `'image/jpeg'`
|
|
282
|
+
* @return the `data:` URL of the raster
|
|
283
|
+
*/
|
|
284
|
+
toDataURL(type?: string, quality?: number): string | null;
|
|
285
|
+
/**
|
|
286
|
+
* Draws an image on the raster.
|
|
287
|
+
*
|
|
288
|
+
* @param image the image to draw
|
|
289
|
+
* @param point the offset of the image as a point in pixel coordinates
|
|
290
|
+
*/
|
|
291
|
+
drawImage(image: CanvasImageSource, point: PointLike): void;
|
|
292
|
+
/**
|
|
293
|
+
* Calculates the average color of the image within the given path,
|
|
294
|
+
* rectangle or point. This can be used for creating raster image effects.
|
|
295
|
+
* Areas smaller than a pixel also take in some of the pixels around them,
|
|
296
|
+
* as the image is sampled smoothly.
|
|
297
|
+
*
|
|
298
|
+
* @param [object] the path, rectangle or point to get the average color
|
|
299
|
+
* of, or none for the whole raster
|
|
300
|
+
* @return the average color contained in the area covered by the specified
|
|
301
|
+
* path, rectangle or point
|
|
302
|
+
*/
|
|
303
|
+
getAverageColor(object?: PathItem | RectangleLike | PointLike): Color | null;
|
|
304
|
+
/**
|
|
305
|
+
* {@grouptitle Pixels}
|
|
306
|
+
* Gets the color of a pixel in the raster.
|
|
307
|
+
*
|
|
308
|
+
* @param x the x offset of the pixel in pixel coordinates
|
|
309
|
+
* @param y the y offset of the pixel in pixel coordinates
|
|
310
|
+
* @return the color of the pixel
|
|
311
|
+
*/
|
|
312
|
+
getPixel(x: number, y: number): Color;
|
|
313
|
+
/**
|
|
314
|
+
* Gets the color of a pixel in the raster.
|
|
315
|
+
*
|
|
316
|
+
* @param point the offset of the pixel as a point in pixel coordinates
|
|
317
|
+
* @return the color of the pixel
|
|
318
|
+
*/
|
|
319
|
+
getPixel(point: PointLike): Color;
|
|
320
|
+
/**
|
|
321
|
+
* Sets the color of the specified pixel to the specified color.
|
|
322
|
+
*
|
|
323
|
+
* @param x the x offset of the pixel in pixel coordinates
|
|
324
|
+
* @param y the y offset of the pixel in pixel coordinates
|
|
325
|
+
* @param color the color that the pixel will be set to
|
|
326
|
+
*/
|
|
327
|
+
setPixel(x: number, y: number, color: ColorLike): void;
|
|
328
|
+
/**
|
|
329
|
+
* Sets the color of the pixel at the specified point to the specified
|
|
330
|
+
* color.
|
|
331
|
+
*
|
|
332
|
+
* @param point the offset of the pixel as a point in pixel coordinates
|
|
333
|
+
* @param color the color that the pixel will be set to
|
|
334
|
+
*/
|
|
335
|
+
setPixel(point: PointLike, color: ColorLike): void;
|
|
336
|
+
/**
|
|
337
|
+
* Clears the image, if it is backed by a canvas.
|
|
338
|
+
*/
|
|
339
|
+
clear(): undefined;
|
|
340
|
+
/**
|
|
341
|
+
* {@grouptitle Image Data}
|
|
342
|
+
*
|
|
343
|
+
* Creates a new, blank image data object of the given size, to fill and
|
|
344
|
+
* pass to {@link #putImageData(data, point)} or
|
|
345
|
+
* {@link #setImageData(data)}.
|
|
346
|
+
*
|
|
347
|
+
* @param size the size of the image data in pixels
|
|
348
|
+
* @return the new image data
|
|
349
|
+
*/
|
|
350
|
+
createImageData(size: SizeLike): ImageData;
|
|
351
|
+
/**
|
|
352
|
+
* Returns the image data of the pixels within the specified rectangle, or
|
|
353
|
+
* of the whole raster if no rectangle or an empty one is passed.
|
|
354
|
+
*
|
|
355
|
+
* @param [rect] the area of the raster to get the image data of, in pixel
|
|
356
|
+
* coordinates
|
|
357
|
+
* @return the image data of the specified area
|
|
358
|
+
*/
|
|
359
|
+
getImageData(rect?: RectangleLike): ImageData;
|
|
360
|
+
/**
|
|
361
|
+
* Draws the image data into the raster at the given offset.
|
|
362
|
+
*
|
|
363
|
+
* @param data the image data to draw
|
|
364
|
+
* @param point the offset of the image data as a point in pixel
|
|
365
|
+
* coordinates
|
|
366
|
+
*/
|
|
367
|
+
putImageData(data: ImageData, point: PointLike): void;
|
|
368
|
+
/**
|
|
369
|
+
* Replaces the raster's pixels with the image data, and resizes the raster
|
|
370
|
+
* to the size of the data.
|
|
371
|
+
*
|
|
372
|
+
* @param data the image data to set
|
|
373
|
+
*/
|
|
374
|
+
setImageData(data: ImageData): void;
|
|
375
|
+
_getBounds(matrix: Matrix | null): Rectangle;
|
|
376
|
+
_hitTestSelf(point: Point): HitResult | null;
|
|
377
|
+
_drawGeometry(ctx: CanvasRenderingContext2D, matrix: Matrix | null): void;
|
|
378
|
+
_draw(ctx: CanvasRenderingContext2D, param: DrawParam, viewMatrix: Matrix): void;
|
|
379
|
+
_canComposite(): boolean;
|
|
380
|
+
}
|
|
381
|
+
export declare function rasterizeItem(item: Item, options?: {
|
|
382
|
+
resolution?: number;
|
|
383
|
+
raster?: Raster;
|
|
384
|
+
insert?: boolean;
|
|
385
|
+
}): Raster;
|
|
386
|
+
/**
|
|
387
|
+
* The rasterizing of items, for `use(raster)` with `paper/core`, see the
|
|
388
|
+
* `use()` function there.
|
|
389
|
+
*/
|
|
390
|
+
export declare const raster: {
|
|
391
|
+
feature: {
|
|
392
|
+
name: "raster";
|
|
393
|
+
rasterizeItem: typeof rasterizeItem;
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
export interface Raster {
|
|
397
|
+
/**
|
|
398
|
+
* {@grouptitle Event Handlers}
|
|
399
|
+
*
|
|
400
|
+
* The event handler function to be called when the underlying image has
|
|
401
|
+
* finished loading and is ready to be used. This is also triggered when
|
|
402
|
+
* the image is already loaded, or when a canvas is used instead of an
|
|
403
|
+
* image.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* var url = 'http://assets.paperjs.org/images/marilyn.jpg';
|
|
407
|
+
* var raster = new Raster(url);
|
|
408
|
+
*
|
|
409
|
+
* // If you create a Raster using a url, you can use the onLoad
|
|
410
|
+
* // handler to do something once it is loaded:
|
|
411
|
+
* raster.onLoad = function() {
|
|
412
|
+
* console.log('The image has finished loading.');
|
|
413
|
+
* };
|
|
414
|
+
*
|
|
415
|
+
* // As with all events in paper.js, you can also use this notation instead
|
|
416
|
+
* // to install multiple handlers:
|
|
417
|
+
* raster.on('load', function() {
|
|
418
|
+
* console.log('Now the image is definitely ready.');
|
|
419
|
+
* });
|
|
420
|
+
*/
|
|
421
|
+
get onLoad(): Handler<this> | null;
|
|
422
|
+
set onLoad(func: Handler<this> | null);
|
|
423
|
+
/**
|
|
424
|
+
*
|
|
425
|
+
* The event handler function to be called when there is an error loading
|
|
426
|
+
* the underlying image.
|
|
427
|
+
*/
|
|
428
|
+
get onError(): Handler<this> | null;
|
|
429
|
+
set onError(func: Handler<this> | null);
|
|
430
|
+
}
|
|
431
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { HitResult, Item, Matrix, Path, Point, Rectangle, Size } from '../internal.ts';
|
|
2
|
+
import type { PointLike } from '../basic/Point.ts';
|
|
3
|
+
import type { SizeLike } from '../basic/Size.ts';
|
|
4
|
+
import type { RectangleLike } from '../basic/Rectangle.ts';
|
|
5
|
+
import type { BoundsOptions } from './Item.ts';
|
|
6
|
+
import type { DrawParam } from './draw.ts';
|
|
7
|
+
import type { HitTestOptions } from './HitResult.ts';
|
|
8
|
+
import type { ItemProps } from './props.ts';
|
|
9
|
+
import type { RectangleProps } from '../path/shapes.ts';
|
|
10
|
+
export type ShapeType = 'rectangle' | 'circle' | 'ellipse';
|
|
11
|
+
/**
|
|
12
|
+
* The Shape item represents a rectangle, with optionally rounded corners, a
|
|
13
|
+
* circle or an ellipse, described by its {@link #type}, {@link #size} and
|
|
14
|
+
* {@link #radius} instead of by segments as a {@link Path} is. Use
|
|
15
|
+
* {@link #toPath(insert)} to convert it to a path.
|
|
16
|
+
*/
|
|
17
|
+
export declare class Shape extends Item {
|
|
18
|
+
_type: ShapeType;
|
|
19
|
+
_size: Size;
|
|
20
|
+
_radius: number | Size;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a circular shape item.
|
|
23
|
+
*
|
|
24
|
+
* @param center the center point of the circle
|
|
25
|
+
* @param radius the radius of the circle
|
|
26
|
+
* @return the newly created shape
|
|
27
|
+
*
|
|
28
|
+
* @example {@paperscript}
|
|
29
|
+
* var shape = Shape.circle(new Point(80, 50), 30);
|
|
30
|
+
* shape.strokeColor = 'black';
|
|
31
|
+
*/
|
|
32
|
+
static circle(center: PointLike, radius: number): Shape;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a circular shape item from the properties described by an
|
|
35
|
+
* object literal.
|
|
36
|
+
*
|
|
37
|
+
* @param object an object containing properties describing the shape's
|
|
38
|
+
* attributes
|
|
39
|
+
* @return the newly created shape
|
|
40
|
+
*
|
|
41
|
+
* @example {@paperscript}
|
|
42
|
+
* var shape = Shape.circle({
|
|
43
|
+
* center: [80, 50],
|
|
44
|
+
* radius: 30,
|
|
45
|
+
* strokeColor: 'black'
|
|
46
|
+
* });
|
|
47
|
+
*/
|
|
48
|
+
static circle(object: {
|
|
49
|
+
center: PointLike;
|
|
50
|
+
radius: number;
|
|
51
|
+
} & ItemProps<Shape>): Shape;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a rectangular shape item, with optionally rounded corners.
|
|
54
|
+
*
|
|
55
|
+
* @param rectangle the rectangle object describing the geometry of the
|
|
56
|
+
* rectangular shape to be created
|
|
57
|
+
* @param [radius=null] the size of the rounded corners
|
|
58
|
+
* @return the newly created shape
|
|
59
|
+
*
|
|
60
|
+
* @example {@paperscript}
|
|
61
|
+
* var rectangle = new Rectangle(new Point(20, 20), new Size(60, 60));
|
|
62
|
+
* var shape = Shape.rectangle(rectangle);
|
|
63
|
+
* shape.strokeColor = 'black';
|
|
64
|
+
*
|
|
65
|
+
* @example {@paperscript} // The same, with rounder corners
|
|
66
|
+
* var rectangle = new Rectangle(new Point(20, 20), new Size(60, 60));
|
|
67
|
+
* var cornerSize = new Size(10, 10);
|
|
68
|
+
* var shape = Shape.rectangle(rectangle, cornerSize);
|
|
69
|
+
* shape.strokeColor = 'black';
|
|
70
|
+
*/
|
|
71
|
+
static rectangle(rectangle: RectangleLike, radius?: SizeLike | number): Shape;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a rectangular shape item from a point and a size object.
|
|
74
|
+
*
|
|
75
|
+
* @param point the rectangle's top-left corner.
|
|
76
|
+
* @param size the rectangle's size.
|
|
77
|
+
* @return the newly created shape
|
|
78
|
+
*
|
|
79
|
+
* @example {@paperscript}
|
|
80
|
+
* var point = new Point(20, 20);
|
|
81
|
+
* var size = new Size(60, 60);
|
|
82
|
+
* var shape = Shape.rectangle(point, size);
|
|
83
|
+
* shape.strokeColor = 'black';
|
|
84
|
+
*/
|
|
85
|
+
static rectangle(point: PointLike, size: SizeLike): Shape;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a rectangular shape item from the passed points. These do not
|
|
88
|
+
* necessarily need to be the top left and bottom right corners, the
|
|
89
|
+
* constructor figures out how to fit a rectangle between them.
|
|
90
|
+
*
|
|
91
|
+
* @param from the first point defining the rectangle
|
|
92
|
+
* @param to the second point defining the rectangle
|
|
93
|
+
* @return the newly created shape
|
|
94
|
+
*
|
|
95
|
+
* @example {@paperscript}
|
|
96
|
+
* var from = new Point(20, 20);
|
|
97
|
+
* var to = new Point(80, 80);
|
|
98
|
+
* var shape = Shape.rectangle(from, to);
|
|
99
|
+
* shape.strokeColor = 'black';
|
|
100
|
+
*/
|
|
101
|
+
static rectangle(from: PointLike, to: PointLike): Shape;
|
|
102
|
+
/**
|
|
103
|
+
* Creates a rectangular shape item from the properties described by an
|
|
104
|
+
* object literal.
|
|
105
|
+
*
|
|
106
|
+
* @param object an object containing properties describing the shape's
|
|
107
|
+
* attributes
|
|
108
|
+
* @return the newly created shape
|
|
109
|
+
*
|
|
110
|
+
* @example {@paperscript}
|
|
111
|
+
* var shape = Shape.rectangle({
|
|
112
|
+
* point: [20, 20],
|
|
113
|
+
* size: [60, 60],
|
|
114
|
+
* strokeColor: 'black'
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* @example {@paperscript}
|
|
118
|
+
* var shape = Shape.rectangle({
|
|
119
|
+
* from: [20, 20],
|
|
120
|
+
* to: [80, 80],
|
|
121
|
+
* strokeColor: 'black'
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* @example {@paperscript}
|
|
125
|
+
* var shape = Shape.rectangle({
|
|
126
|
+
* rectangle: {
|
|
127
|
+
* topLeft: [20, 20],
|
|
128
|
+
* bottomRight: [80, 80]
|
|
129
|
+
* },
|
|
130
|
+
* strokeColor: 'black'
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* @example {@paperscript}
|
|
134
|
+
* var shape = Shape.rectangle({
|
|
135
|
+
* topLeft: [20, 20],
|
|
136
|
+
* bottomRight: [80, 80],
|
|
137
|
+
* radius: 10,
|
|
138
|
+
* strokeColor: 'black'
|
|
139
|
+
* });
|
|
140
|
+
*/
|
|
141
|
+
static rectangle(object: RectangleProps & ItemProps<Shape>): Shape;
|
|
142
|
+
/**
|
|
143
|
+
* Creates an elliptical shape item.
|
|
144
|
+
*
|
|
145
|
+
* @param rectangle the rectangle circumscribing the ellipse
|
|
146
|
+
* @return the newly created shape
|
|
147
|
+
*
|
|
148
|
+
* @example {@paperscript}
|
|
149
|
+
* var rectangle = new Rectangle(new Point(20, 20), new Size(180, 60));
|
|
150
|
+
* var shape = Shape.ellipse(rectangle);
|
|
151
|
+
* shape.fillColor = 'black';
|
|
152
|
+
*/
|
|
153
|
+
static ellipse(rectangle: RectangleLike): Shape;
|
|
154
|
+
/**
|
|
155
|
+
* Creates an elliptical shape item from the properties described by an
|
|
156
|
+
* object literal.
|
|
157
|
+
*
|
|
158
|
+
* @param object an object containing properties describing the shape's
|
|
159
|
+
* attributes
|
|
160
|
+
* @return the newly created shape
|
|
161
|
+
*
|
|
162
|
+
* @example {@paperscript}
|
|
163
|
+
* var shape = Shape.ellipse({
|
|
164
|
+
* point: [20, 20],
|
|
165
|
+
* size: [180, 60],
|
|
166
|
+
* fillColor: 'black'
|
|
167
|
+
* });
|
|
168
|
+
*
|
|
169
|
+
* @example {@paperscript} // Placing by center and radius
|
|
170
|
+
* var shape = Shape.ellipse({
|
|
171
|
+
* center: [110, 50],
|
|
172
|
+
* radius: [90, 30],
|
|
173
|
+
* fillColor: 'black'
|
|
174
|
+
* });
|
|
175
|
+
*/
|
|
176
|
+
static ellipse(object: RectangleProps & ItemProps<Shape>): Shape;
|
|
177
|
+
constructor(props?: ItemProps<Shape>, point?: PointLike);
|
|
178
|
+
_equals(item: Item): boolean;
|
|
179
|
+
copyContent(source: this): void;
|
|
180
|
+
/**
|
|
181
|
+
* The type of shape of the item as a string.
|
|
182
|
+
*
|
|
183
|
+
* @values 'rectangle', 'circle', 'ellipse'
|
|
184
|
+
*/
|
|
185
|
+
get type(): ShapeType;
|
|
186
|
+
set type(type: ShapeType);
|
|
187
|
+
/**
|
|
188
|
+
* The size of the shape.
|
|
189
|
+
*/
|
|
190
|
+
get size(): Size;
|
|
191
|
+
set size(value: SizeLike | number);
|
|
192
|
+
/**
|
|
193
|
+
* The radius of the shape, as a number if it is a circle, or a size object
|
|
194
|
+
* for ellipses and rounded rectangles.
|
|
195
|
+
*/
|
|
196
|
+
get radius(): number | Size;
|
|
197
|
+
set radius(value: number | SizeLike);
|
|
198
|
+
isEmpty(): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Creates a new path item with same geometry as this shape item, and
|
|
201
|
+
* inherits all settings from it, similar to {@link Item#clone()}.
|
|
202
|
+
*
|
|
203
|
+
* @param [insert=true] specifies whether the new path should be inserted
|
|
204
|
+
* into the scene graph. When set to `true`, it is inserted above the
|
|
205
|
+
* shape item
|
|
206
|
+
* @return the newly created path item with the same geometry as this shape
|
|
207
|
+
* item
|
|
208
|
+
* @see Path#toShape(insert)
|
|
209
|
+
*/
|
|
210
|
+
toPath(insert?: boolean): Path;
|
|
211
|
+
toShape(insert?: boolean): Shape;
|
|
212
|
+
_asPathItem(): Path;
|
|
213
|
+
_draw(ctx: CanvasRenderingContext2D, param: DrawParam, viewMatrix: Matrix, strokeMatrix?: Matrix | null): void;
|
|
214
|
+
_drawGeometry(ctx: CanvasRenderingContext2D, matrix: Matrix | null): void;
|
|
215
|
+
_canComposite(): boolean;
|
|
216
|
+
_getBounds(matrix: Matrix | null, options: BoundsOptions): Rectangle;
|
|
217
|
+
_contains(point: Point): boolean;
|
|
218
|
+
_hitTestSelf(point: Point, options: HitTestOptions, viewMatrix?: Matrix | null, strokeMatrix?: Matrix | null): HitResult | null;
|
|
219
|
+
}
|