paper 0.17.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.
Files changed (474) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/LICENSE.txt +1 -1
  3. package/MIGRATION.md +402 -0
  4. package/README.md +137 -143
  5. package/dist/esm/anim/Tween.js +404 -0
  6. package/dist/esm/basic/Line.js +252 -0
  7. package/dist/esm/basic/Matrix.js +603 -0
  8. package/dist/esm/basic/Point.js +738 -0
  9. package/dist/esm/basic/Rectangle.js +788 -0
  10. package/dist/esm/basic/Size.js +368 -0
  11. package/dist/esm/boolean/graph.js +950 -0
  12. package/dist/esm/boolean/index.js +143 -0
  13. package/dist/esm/boolean/operations.js +94 -0
  14. package/dist/esm/boolean/split.js +89 -0
  15. package/dist/esm/canvas/blendModes.js +115 -0
  16. package/dist/esm/canvas/canvasProvider.js +102 -0
  17. package/dist/esm/constants.js +130 -0
  18. package/dist/esm/core/Base.js +52 -0
  19. package/dist/esm/core/Emitter.js +215 -0
  20. package/dist/esm/core/features.js +53 -0
  21. package/dist/esm/core/serialization.js +174 -0
  22. package/dist/esm/core.js +15 -0
  23. package/dist/esm/dom/domElement.js +112 -0
  24. package/dist/esm/dom/domEvent.js +106 -0
  25. package/dist/esm/env.js +66 -0
  26. package/dist/esm/event/DrawEvent.js +38 -0
  27. package/dist/esm/event/Event.js +79 -0
  28. package/dist/esm/event/Key.js +236 -0
  29. package/dist/esm/event/KeyEvent.js +39 -0
  30. package/dist/esm/event/MouseEvent.js +91 -0
  31. package/dist/esm/hosted/HostItem.js +60 -0
  32. package/dist/esm/hosted/Hosting.js +1061 -0
  33. package/dist/esm/hosted/index.js +20 -0
  34. package/dist/esm/index.js +38 -0
  35. package/dist/esm/internal.js +115 -0
  36. package/dist/esm/item/Effect.js +256 -0
  37. package/dist/esm/item/EffectInstance.js +184 -0
  38. package/dist/esm/item/Group.js +293 -0
  39. package/dist/esm/item/HitResult.js +126 -0
  40. package/dist/esm/item/Item.js +3339 -0
  41. package/dist/esm/item/ItemDefinition.js +95 -0
  42. package/dist/esm/item/Layer.js +69 -0
  43. package/dist/esm/item/Project.js +1013 -0
  44. package/dist/esm/item/Raster.js +722 -0
  45. package/dist/esm/item/Shape.js +355 -0
  46. package/dist/esm/item/SymbolDefinition.js +68 -0
  47. package/dist/esm/item/SymbolItem.js +131 -0
  48. package/dist/esm/item/bounds.js +324 -0
  49. package/dist/esm/item/draw.js +525 -0
  50. package/dist/esm/item/effects.js +124 -0
  51. package/dist/esm/item/expand.js +87 -0
  52. package/dist/esm/item/hitTest.js +203 -0
  53. package/dist/esm/item/hosting.js +12 -0
  54. package/dist/esm/item/props.js +12 -0
  55. package/dist/esm/item/query.js +139 -0
  56. package/dist/esm/item/sampling.js +67 -0
  57. package/dist/esm/item/transform.js +128 -0
  58. package/dist/esm/net/http.js +26 -0
  59. package/dist/esm/node/CanvasAdapter.js +137 -0
  60. package/dist/esm/node/index.js +150 -0
  61. package/dist/esm/node/peers.js +27 -0
  62. package/dist/esm/offset/curves.js +866 -0
  63. package/dist/esm/offset/index.js +70 -0
  64. package/dist/esm/offset/offset.js +178 -0
  65. package/dist/esm/offset/outline.js +91 -0
  66. package/dist/esm/offset/pen.js +298 -0
  67. package/dist/esm/offset/profile.js +772 -0
  68. package/dist/esm/offset/round.js +213 -0
  69. package/dist/esm/offset/sweep.js +100 -0
  70. package/dist/esm/paperscript/PaperScript.js +832 -0
  71. package/dist/esm/paperscript/autoload.js +27 -0
  72. package/dist/esm/paperscript/index.js +17 -0
  73. package/dist/esm/path/CompoundPath.js +367 -0
  74. package/dist/esm/path/Curve.js +996 -0
  75. package/dist/esm/path/CurveLocation.js +462 -0
  76. package/dist/esm/path/Path.js +1761 -0
  77. package/dist/esm/path/PathFlattener.js +186 -0
  78. package/dist/esm/path/PathItem.js +757 -0
  79. package/dist/esm/path/Segment.js +640 -0
  80. package/dist/esm/path/SegmentPoint.js +106 -0
  81. package/dist/esm/path/StrokeProfile.js +387 -0
  82. package/dist/esm/path/StrokeProfileStop.js +207 -0
  83. package/dist/esm/path/boolean.js +284 -0
  84. package/dist/esm/path/bounds.js +257 -0
  85. package/dist/esm/path/crossing.js +114 -0
  86. package/dist/esm/path/draw.js +161 -0
  87. package/dist/esm/path/hitTest.js +259 -0
  88. package/dist/esm/path/offset.js +152 -0
  89. package/dist/esm/path/shapes.js +231 -0
  90. package/dist/esm/path/smooth.js +84 -0
  91. package/dist/esm/path/values.js +40 -0
  92. package/dist/esm/scope/PaperScope.js +288 -0
  93. package/dist/esm/scope/PaperScopeItem.js +74 -0
  94. package/dist/esm/smoothing/index.js +71 -0
  95. package/dist/esm/style/Color.js +917 -0
  96. package/dist/esm/style/Gradient.js +191 -0
  97. package/dist/esm/style/GradientStop.js +168 -0
  98. package/dist/esm/style/PatternDefinition.js +383 -0
  99. package/dist/esm/style/Style.js +503 -0
  100. package/dist/esm/svg/index.js +27 -0
  101. package/dist/esm/svg/svgElement.js +97 -0
  102. package/dist/esm/svg/svgExport.js +847 -0
  103. package/dist/esm/svg/svgImport.js +1101 -0
  104. package/dist/esm/svg/svgStyles.js +96 -0
  105. package/dist/esm/text/AreaText.js +190 -0
  106. package/dist/esm/text/PathText.js +111 -0
  107. package/dist/esm/text/PointText.js +92 -0
  108. package/dist/esm/text/TextItem.js +538 -0
  109. package/dist/esm/text/TextRange.js +169 -0
  110. package/dist/esm/text/TextStory.js +394 -0
  111. package/dist/esm/text/areaLayout.js +439 -0
  112. package/dist/esm/text/layout.js +265 -0
  113. package/dist/esm/text/measure.js +57 -0
  114. package/dist/esm/text/pathLayout.js +93 -0
  115. package/dist/esm/tool/Tool.js +284 -0
  116. package/dist/esm/tool/ToolEvent.js +232 -0
  117. package/dist/esm/util/Formatter.js +57 -0
  118. package/dist/esm/util/collisions.js +216 -0
  119. package/dist/esm/util/list.js +110 -0
  120. package/dist/esm/util/numerical.js +656 -0
  121. package/dist/esm/util/object.js +81 -0
  122. package/dist/esm/util/string.js +29 -0
  123. package/dist/esm/util/uid.js +31 -0
  124. package/dist/esm/values/arcs.js +243 -0
  125. package/dist/esm/values/curve.js +975 -0
  126. package/dist/esm/values/fit.js +290 -0
  127. package/dist/esm/values/index.js +23 -0
  128. package/dist/esm/values/intersections.js +869 -0
  129. package/dist/esm/values/matrix.js +114 -0
  130. package/dist/esm/values/path.js +174 -0
  131. package/dist/esm/values/profile.js +221 -0
  132. package/dist/esm/values/region.js +63 -0
  133. package/dist/esm/values/smooth.js +248 -0
  134. package/dist/esm/values/svg.js +287 -0
  135. package/dist/esm/view/CanvasView.js +106 -0
  136. package/dist/esm/view/View.js +775 -0
  137. package/dist/esm/view/input.js +527 -0
  138. package/dist/paper-full.js +32941 -26371
  139. package/dist/paper-full.min.js +36 -31
  140. package/dist/paper-hosted.js +33623 -27236
  141. package/dist/paper-hosted.min.js +37 -0
  142. package/dist/paper-slim.js +28581 -0
  143. package/dist/paper-slim.min.js +17 -0
  144. package/dist/types/anim/Tween.d.ts +164 -0
  145. package/dist/types/basic/Line.d.ts +136 -0
  146. package/dist/types/basic/Matrix.d.ts +387 -0
  147. package/dist/types/basic/Point.d.ts +781 -0
  148. package/dist/types/basic/Rectangle.d.ts +550 -0
  149. package/dist/types/basic/Size.d.ts +457 -0
  150. package/dist/types/boolean/graph.d.ts +123 -0
  151. package/dist/types/boolean/index.d.ts +74 -0
  152. package/dist/types/boolean/operations.d.ts +9 -0
  153. package/dist/types/boolean/split.d.ts +19 -0
  154. package/dist/types/canvas/blendModes.d.ts +18 -0
  155. package/dist/types/canvas/canvasProvider.d.ts +32 -0
  156. package/dist/types/constants.d.ts +112 -0
  157. package/dist/types/core/Base.d.ts +50 -0
  158. package/dist/types/core/Emitter.d.ts +49 -0
  159. package/dist/types/core/features.d.ts +41 -0
  160. package/dist/types/core/serialization.d.ts +44 -0
  161. package/dist/types/core.d.ts +18 -0
  162. package/dist/types/dom/domElement.d.ts +33 -0
  163. package/dist/types/dom/domEvent.d.ts +29 -0
  164. package/dist/types/env.d.ts +26 -0
  165. package/dist/types/event/DrawEvent.d.ts +27 -0
  166. package/dist/types/event/Event.d.ts +47 -0
  167. package/dist/types/event/Key.d.ts +82 -0
  168. package/dist/types/event/KeyEvent.d.ts +35 -0
  169. package/dist/types/event/MouseEvent.d.ts +78 -0
  170. package/dist/types/hosted/HostItem.d.ts +26 -0
  171. package/dist/types/hosted/Hosting.d.ts +273 -0
  172. package/dist/types/hosted/index.d.ts +10 -0
  173. package/dist/types/index.d.ts +64 -0
  174. package/dist/types/internal.d.ts +101 -0
  175. package/dist/types/item/Effect.d.ts +128 -0
  176. package/dist/types/item/EffectInstance.d.ts +81 -0
  177. package/dist/types/item/Group.d.ts +225 -0
  178. package/dist/types/item/HitResult.d.ts +94 -0
  179. package/dist/types/item/Item.d.ts +2927 -0
  180. package/dist/types/item/ItemDefinition.d.ts +25 -0
  181. package/dist/types/item/Layer.d.ts +80 -0
  182. package/dist/types/item/Project.d.ts +748 -0
  183. package/dist/types/item/Raster.d.ts +431 -0
  184. package/dist/types/item/Shape.d.ts +219 -0
  185. package/dist/types/item/SymbolDefinition.d.ts +98 -0
  186. package/dist/types/item/SymbolItem.d.ts +92 -0
  187. package/dist/types/item/bounds.d.ts +56 -0
  188. package/dist/types/item/draw.d.ts +23 -0
  189. package/dist/types/item/effects.d.ts +22 -0
  190. package/dist/types/item/expand.d.ts +7 -0
  191. package/dist/types/item/hitTest.d.ts +10 -0
  192. package/dist/types/item/hosting.d.ts +20 -0
  193. package/dist/types/item/props.d.ts +35 -0
  194. package/dist/types/item/query.d.ts +14 -0
  195. package/dist/types/item/sampling.d.ts +5 -0
  196. package/dist/types/item/transform.d.ts +3 -0
  197. package/dist/types/net/http.d.ts +6 -0
  198. package/dist/types/node/CanvasAdapter.d.ts +19 -0
  199. package/dist/types/node/index.d.ts +60 -0
  200. package/dist/types/node/peers.d.ts +2 -0
  201. package/dist/types/offset/curves.d.ts +22 -0
  202. package/dist/types/offset/index.d.ts +65 -0
  203. package/dist/types/offset/offset.d.ts +18 -0
  204. package/dist/types/offset/outline.d.ts +14 -0
  205. package/dist/types/offset/pen.d.ts +36 -0
  206. package/dist/types/offset/profile.d.ts +37 -0
  207. package/dist/types/offset/round.d.ts +18 -0
  208. package/dist/types/offset/sweep.d.ts +44 -0
  209. package/dist/types/paperscript/PaperScript.d.ts +114 -0
  210. package/dist/types/paperscript/autoload.d.ts +1 -0
  211. package/dist/types/paperscript/index.d.ts +7 -0
  212. package/dist/types/path/CompoundPath.d.ts +183 -0
  213. package/dist/types/path/Curve.d.ts +567 -0
  214. package/dist/types/path/CurveLocation.d.ts +164 -0
  215. package/dist/types/path/Path.d.ts +1361 -0
  216. package/dist/types/path/PathFlattener.d.ts +48 -0
  217. package/dist/types/path/PathItem.d.ts +1190 -0
  218. package/dist/types/path/Segment.d.ts +335 -0
  219. package/dist/types/path/SegmentPoint.d.ts +1 -0
  220. package/dist/types/path/StrokeProfile.d.ts +74 -0
  221. package/dist/types/path/StrokeProfileStop.d.ts +110 -0
  222. package/dist/types/path/boolean.d.ts +24 -0
  223. package/dist/types/path/bounds.d.ts +24 -0
  224. package/dist/types/path/crossing.d.ts +2 -0
  225. package/dist/types/path/draw.d.ts +6 -0
  226. package/dist/types/path/hitTest.d.ts +8 -0
  227. package/dist/types/path/offset.d.ts +14 -0
  228. package/dist/types/path/shapes.d.ts +20 -0
  229. package/dist/types/path/smooth.d.ts +18 -0
  230. package/dist/types/path/values.d.ts +8 -0
  231. package/dist/types/scope/PaperScope.d.ts +182 -0
  232. package/dist/types/scope/PaperScopeItem.d.ts +26 -0
  233. package/dist/types/smoothing/index.d.ts +26 -0
  234. package/dist/types/style/Color.d.ts +829 -0
  235. package/dist/types/style/Gradient.d.ts +130 -0
  236. package/dist/types/style/GradientStop.d.ts +126 -0
  237. package/dist/types/style/PatternDefinition.d.ts +185 -0
  238. package/dist/types/style/Style.d.ts +757 -0
  239. package/dist/types/svg/index.d.ts +14 -0
  240. package/dist/types/svg/svgElement.d.ts +32 -0
  241. package/dist/types/svg/svgExport.d.ts +19 -0
  242. package/dist/types/svg/svgImport.d.ts +13 -0
  243. package/dist/types/svg/svgStyles.d.ts +20 -0
  244. package/dist/types/text/AreaText.d.ts +104 -0
  245. package/dist/types/text/PathText.d.ts +78 -0
  246. package/dist/types/text/PointText.d.ts +50 -0
  247. package/dist/types/text/TextItem.d.ts +163 -0
  248. package/dist/types/text/TextRange.d.ts +98 -0
  249. package/dist/types/text/TextStory.d.ts +119 -0
  250. package/dist/types/text/areaLayout.d.ts +3 -0
  251. package/dist/types/text/layout.d.ts +43 -0
  252. package/dist/types/text/measure.d.ts +7 -0
  253. package/dist/types/text/pathLayout.d.ts +3 -0
  254. package/dist/types/tool/Tool.d.ts +356 -0
  255. package/dist/types/tool/ToolEvent.d.ts +134 -0
  256. package/dist/types/util/Formatter.d.ts +34 -0
  257. package/dist/types/util/collisions.d.ts +77 -0
  258. package/dist/types/util/list.d.ts +23 -0
  259. package/dist/types/util/numerical.d.ts +196 -0
  260. package/dist/types/util/object.d.ts +19 -0
  261. package/dist/types/util/string.d.ts +12 -0
  262. package/dist/types/util/uid.d.ts +7 -0
  263. package/dist/types/values/arcs.d.ts +10 -0
  264. package/dist/types/values/curve.d.ts +42 -0
  265. package/dist/types/values/fit.d.ts +26 -0
  266. package/dist/types/values/index.d.ts +10 -0
  267. package/dist/types/values/intersections.d.ts +11 -0
  268. package/dist/types/values/matrix.d.ts +19 -0
  269. package/dist/types/values/path.d.ts +26 -0
  270. package/dist/types/values/profile.d.ts +41 -0
  271. package/dist/types/values/region.d.ts +13 -0
  272. package/dist/types/values/smooth.d.ts +39 -0
  273. package/dist/types/values/svg.d.ts +47 -0
  274. package/dist/types/view/CanvasView.d.ts +37 -0
  275. package/dist/types/view/View.d.ts +700 -0
  276. package/dist/types/view/input.d.ts +28 -0
  277. package/package.json +89 -59
  278. package/dist/docs/assets/css/docs.css +0 -414
  279. package/dist/docs/assets/js/codemirror.js +0 -4
  280. package/dist/docs/assets/js/docs.js +0 -493
  281. package/dist/docs/assets/js/jquery.js +0 -6
  282. package/dist/docs/assets/js/paper.js +0 -27591
  283. package/dist/docs/classes/AreaText.html +0 -9186
  284. package/dist/docs/classes/ChangeFlag.html +0 -385
  285. package/dist/docs/classes/Color.html +0 -2402
  286. package/dist/docs/classes/CompoundPath.html +0 -10018
  287. package/dist/docs/classes/Curve.html +0 -2326
  288. package/dist/docs/classes/CurveLocation.html +0 -673
  289. package/dist/docs/classes/DrawEvent.html +0 -69
  290. package/dist/docs/classes/Effect.html +0 -434
  291. package/dist/docs/classes/EffectInstance.html +0 -304
  292. package/dist/docs/classes/Event.html +0 -177
  293. package/dist/docs/classes/Gradient.html +0 -241
  294. package/dist/docs/classes/GradientStop.html +0 -274
  295. package/dist/docs/classes/Group.html +0 -7688
  296. package/dist/docs/classes/HitResult.html +0 -241
  297. package/dist/docs/classes/HostItem.html +0 -7314
  298. package/dist/docs/classes/Item.html +0 -7427
  299. package/dist/docs/classes/Key.html +0 -140
  300. package/dist/docs/classes/KeyEvent.html +0 -309
  301. package/dist/docs/classes/Layer.html +0 -7671
  302. package/dist/docs/classes/Matrix.html +0 -1745
  303. package/dist/docs/classes/MouseEvent.html +0 -356
  304. package/dist/docs/classes/PaperScope.html +0 -548
  305. package/dist/docs/classes/PaperScript.html +0 -204
  306. package/dist/docs/classes/Path.html +0 -13007
  307. package/dist/docs/classes/PathItem.html +0 -9780
  308. package/dist/docs/classes/PathText.html +0 -9056
  309. package/dist/docs/classes/PatternDefinition.html +0 -367
  310. package/dist/docs/classes/Point.html +0 -2860
  311. package/dist/docs/classes/PointText.html +0 -8967
  312. package/dist/docs/classes/Project.html +0 -1774
  313. package/dist/docs/classes/Raster.html +0 -8547
  314. package/dist/docs/classes/Rectangle.html +0 -1698
  315. package/dist/docs/classes/Segment.html +0 -1017
  316. package/dist/docs/classes/Shape.html +0 -8048
  317. package/dist/docs/classes/Size.html +0 -1915
  318. package/dist/docs/classes/StrokeProfileStop.html +0 -346
  319. package/dist/docs/classes/Style.html +0 -1765
  320. package/dist/docs/classes/SymbolDefinition.html +0 -338
  321. package/dist/docs/classes/SymbolItem.html +0 -7477
  322. package/dist/docs/classes/TextItem.html +0 -8810
  323. package/dist/docs/classes/TextRange.html +0 -186
  324. package/dist/docs/classes/TextStory.html +0 -355
  325. package/dist/docs/classes/Tool.html +0 -888
  326. package/dist/docs/classes/ToolEvent.html +0 -525
  327. package/dist/docs/classes/Tween.html +0 -390
  328. package/dist/docs/classes/View.html +0 -2108
  329. package/dist/docs/classes/global.html +0 -426
  330. package/dist/docs/classes/index.html +0 -88
  331. package/dist/docs/index.html +0 -11
  332. package/dist/node/browser.js +0 -15
  333. package/dist/node/canvas.js +0 -68
  334. package/dist/node/extend.js +0 -156
  335. package/dist/node/self.js +0 -67
  336. package/dist/paper-core.d.ts +0 -1
  337. package/dist/paper-core.js +0 -25636
  338. package/dist/paper-core.min.js +0 -32
  339. package/dist/paper.d.ts +0 -10481
  340. package/examples/Animated/AnimatedStar.html +0 -53
  341. package/examples/Animated/BooleanOperations.html +0 -115
  342. package/examples/Animated/CandyCrash.html +0 -151
  343. package/examples/Animated/Extruded.html +0 -50
  344. package/examples/Animated/Lines.html +0 -53
  345. package/examples/Animated/Smoothing.html +0 -70
  346. package/examples/Animated/Space.html +0 -86
  347. package/examples/Animated/SpaceUsingShapes.html +0 -79
  348. package/examples/Games/Paperoids.html +0 -569
  349. package/examples/JSON/Circle Testing.html +0 -34
  350. package/examples/JSON/Compound Path.html +0 -25
  351. package/examples/JSON/Empty Path Testing.html +0 -31
  352. package/examples/JSON/Gradients.html +0 -34
  353. package/examples/JSON/Group Transform.html +0 -28
  354. package/examples/JSON/Line Testing.html +0 -44
  355. package/examples/JSON/Random Path Testing.html +0 -42
  356. package/examples/JSON/Raster.html +0 -29
  357. package/examples/JSON/Rect and Attribute Testing.html +0 -56
  358. package/examples/JSON/Rotated Primitives.html +0 -55
  359. package/examples/JSON/Selection.html +0 -43
  360. package/examples/JSON/Shapes.html +0 -54
  361. package/examples/JSON/Symbols.html +0 -30
  362. package/examples/JSON/Text Testing.html +0 -38
  363. package/examples/JSON/Tiger.html +0 -19
  364. package/examples/JSON/Transform Test 1.html +0 -32
  365. package/examples/JSON/Transform Test 2.html +0 -30
  366. package/examples/Node.js/AnimatedStar.js +0 -52
  367. package/examples/Node.js/BooleanOperations.js +0 -36
  368. package/examples/Node.js/JSONtoPDF.js +0 -20
  369. package/examples/Node.js/Raster.js +0 -32
  370. package/examples/Node.js/RasterRemote.js +0 -33
  371. package/examples/Node.js/SvgExport.js +0 -52
  372. package/examples/Node.js/SvgImport.js +0 -23
  373. package/examples/Node.js/Tadpoles.js +0 -16
  374. package/examples/Node.js/Tadpoles.pjs +0 -278
  375. package/examples/Node.js/in.json +0 -1
  376. package/examples/Node.js/in.svg +0 -16
  377. package/examples/Paperjs.org/BooleanOperattions.html +0 -115
  378. package/examples/Paperjs.org/BouncingBalls.html +0 -103
  379. package/examples/Paperjs.org/Chain.html +0 -54
  380. package/examples/Paperjs.org/DivisionRaster.html +0 -72
  381. package/examples/Paperjs.org/FutureSplash.html +0 -122
  382. package/examples/Paperjs.org/HitTesting.html +0 -103
  383. package/examples/Paperjs.org/InteractiveTiger.html +0 -777
  384. package/examples/Paperjs.org/LiveEffects.html +0 -366
  385. package/examples/Paperjs.org/MetaBalls.html +0 -132
  386. package/examples/Paperjs.org/NyanRainbow.html +0 -202
  387. package/examples/Paperjs.org/Offsetting.html +0 -379
  388. package/examples/Paperjs.org/PathIntersections.html +0 -76
  389. package/examples/Paperjs.org/Qbertify.html +0 -146
  390. package/examples/Paperjs.org/RadialRainbows.html +0 -80
  391. package/examples/Paperjs.org/RoundedRectangles.html +0 -41
  392. package/examples/Paperjs.org/SatieLikedToDraw.html +0 -140
  393. package/examples/Paperjs.org/Simplify.html +0 -63
  394. package/examples/Paperjs.org/SpiralRaster.html +0 -120
  395. package/examples/Paperjs.org/StrokeProfiles.html +0 -706
  396. package/examples/Paperjs.org/Tadpoles.html +0 -283
  397. package/examples/Paperjs.org/Voronoi.html +0 -134
  398. package/examples/Rasters/PhyllotaxisRaster.html +0 -96
  399. package/examples/Rasters/Raster.html +0 -34
  400. package/examples/Rasters/RotationRaster.html +0 -44
  401. package/examples/Rasters/Smoothing.html +0 -36
  402. package/examples/SVG Export/Circle Testing.html +0 -32
  403. package/examples/SVG Export/Clipping.html +0 -17
  404. package/examples/SVG Export/Compound Path.html +0 -22
  405. package/examples/SVG Export/Empty Path Testing.html +0 -28
  406. package/examples/SVG Export/Gradients.html +0 -52
  407. package/examples/SVG Export/Group Transform.html +0 -25
  408. package/examples/SVG Export/Line Testing.html +0 -41
  409. package/examples/SVG Export/Random Path Testing.html +0 -39
  410. package/examples/SVG Export/Raster.html +0 -21
  411. package/examples/SVG Export/Rect and Attribute Testing.html +0 -53
  412. package/examples/SVG Export/Rotated Primitives.html +0 -80
  413. package/examples/SVG Export/Shapes.html +0 -58
  414. package/examples/SVG Export/Symbols.html +0 -27
  415. package/examples/SVG Export/Text Testing.html +0 -45
  416. package/examples/SVG Export/Tiger.html +0 -23
  417. package/examples/SVG Export/Transform Test 1.html +0 -29
  418. package/examples/SVG Export/Transform Test 2.html +0 -27
  419. package/examples/SVG Import/Arcs.html +0 -78
  420. package/examples/SVG Import/Butterfly.html +0 -223
  421. package/examples/SVG Import/Circle and Ellipse Testing.html +0 -26
  422. package/examples/SVG Import/Clipping.html +0 -100
  423. package/examples/SVG Import/From File.html +0 -30
  424. package/examples/SVG Import/Gradient.html +0 -138
  425. package/examples/SVG Import/Gradients.html +0 -30
  426. package/examples/SVG Import/Inkscape Pivot.html +0 -52
  427. package/examples/SVG Import/Inkscape.html +0 -88
  428. package/examples/SVG Import/Line Testing.html +0 -24
  429. package/examples/SVG Import/MoreGradients.html +0 -107
  430. package/examples/SVG Import/Multiple Paths Test 1.html +0 -42
  431. package/examples/SVG Import/Multiple Paths Test 2.html +0 -33
  432. package/examples/SVG Import/Nested Groups Test.html +0 -78
  433. package/examples/SVG Import/Polybezier.html +0 -43
  434. package/examples/SVG Import/Rect Testing.html +0 -25
  435. package/examples/SVG Import/Symbols.html +0 -24
  436. package/examples/SVG Import/Testing.html +0 -40
  437. package/examples/SVG Import/Text Testing.html +0 -19
  438. package/examples/SVG Import/Tiger.html +0 -742
  439. package/examples/SVG Import/Transform Testing.html +0 -22
  440. package/examples/SVG Import/Viewbox.html +0 -38
  441. package/examples/Scripts/Arcs.html +0 -39
  442. package/examples/Scripts/AreaText.html +0 -65
  443. package/examples/Scripts/BlendModes.html +0 -77
  444. package/examples/Scripts/BooleanOperations.html +0 -937
  445. package/examples/Scripts/CompoundPath.html +0 -19
  446. package/examples/Scripts/CurveTimeParameterization.html +0 -61
  447. package/examples/Scripts/HslColor.html +0 -53
  448. package/examples/Scripts/PathStructure.html +0 -82
  449. package/examples/Scripts/PathTangents.html +0 -73
  450. package/examples/Scripts/PathText.html +0 -48
  451. package/examples/Scripts/Patterns.html +0 -57
  452. package/examples/Scripts/Resize.html +0 -42
  453. package/examples/Scripts/RoundRectangle.html +0 -28
  454. package/examples/Scripts/Shapes.html +0 -54
  455. package/examples/Scripts/StrokeBounds.html +0 -101
  456. package/examples/Scripts/StrokeScaling.html +0 -65
  457. package/examples/Scripts/TextRanges.html +0 -51
  458. package/examples/Tools/BezierTool.html +0 -90
  459. package/examples/Tools/Circles.html +0 -28
  460. package/examples/Tools/Clouds.html +0 -35
  461. package/examples/Tools/DrippingBrush.html +0 -73
  462. package/examples/Tools/FancyBrush.html +0 -82
  463. package/examples/Tools/Grid.html +0 -44
  464. package/examples/Tools/MultiLines.html +0 -44
  465. package/examples/Tools/MultipleTools.html +0 -44
  466. package/examples/Tools/PathEditing.html +0 -95
  467. package/examples/Tools/SquareRounded.html +0 -76
  468. package/examples/Tools/Stars.html +0 -38
  469. package/examples/Tools/Vektor.html +0 -200
  470. package/examples/Tools/Wave.html +0 -50
  471. package/examples/Tools/WormFarm.html +0 -88
  472. package/examples/Worker/Main.html +0 -53
  473. package/examples/Worker/Worker.js +0 -14
  474. package/examples/css/style.css +0 -12
@@ -0,0 +1,2927 @@
1
+ import { Emitter, HitResult, Layer, Matrix, Point, Rectangle, Size, Style } from '../internal.ts';
2
+ import type { PaperScope } from '../scope/PaperScope.ts';
3
+ import type { ExpandOptions } from './expand.ts';
4
+ import type { EffectInstance } from './EffectInstance.ts';
5
+ import type { Raster } from './Raster.ts';
6
+ import type { Tween } from '../anim/Tween.ts';
7
+ import type { PointLike, SelectablePoint } from '../basic/Point.ts';
8
+ import type { RectangleLike, SelectableRectangle } from '../basic/Rectangle.ts';
9
+ import type { ItemStyleProperties } from '../style/Style.ts';
10
+ import type { Project } from './Project.ts';
11
+ import type { SymbolDefinition } from './SymbolDefinition.ts';
12
+ import type { View } from '../view/View.ts';
13
+ import type { PathItem } from '../path/PathItem.ts';
14
+ import type { ItemDefinition } from './ItemDefinition.ts';
15
+ import type { BlendMode } from '../canvas/blendModes.ts';
16
+ import type { DrawParam } from './draw.ts';
17
+ import type { HitTestOptions } from './HitResult.ts';
18
+ import type { EventHandler, EventHandlers, EventType } from '../core/Emitter.ts';
19
+ import type { MouseEvent } from '../event/MouseEvent.ts';
20
+ import type { DrawEvent } from '../event/DrawEvent.ts';
21
+ import type { FrameEvent } from '../view/View.ts';
22
+ import type { ItemProps } from './props.ts';
23
+ import type { SVGExportOptions } from '../svg/svgExport.ts';
24
+ import type { SVGImportOptions } from '../svg/svgImport.ts';
25
+ import type { MatchOptions } from './query.ts';
26
+ import type { JSONDictionary, JSONOptions } from '../core/serialization.ts';
27
+ export type Handler<T = Item, E = any> = {
28
+ handle(this: T, event: E, ...args: any[]): any;
29
+ }['handle'];
30
+ export type EffectProps = {
31
+ type: string;
32
+ parameters?: Record<string, unknown>;
33
+ visible?: boolean;
34
+ };
35
+ type TweenOptions = {
36
+ duration?: number;
37
+ easing?: string | ((t: number) => number);
38
+ start?: boolean;
39
+ };
40
+ export type TransformOptions = {
41
+ strokes?: boolean;
42
+ gradients?: boolean;
43
+ patterns?: boolean;
44
+ };
45
+ export type InternalTransformOptions = TransformOptions & {
46
+ recursively?: boolean;
47
+ setApplyMatrix?: boolean;
48
+ isDirect?: boolean;
49
+ };
50
+ /**
51
+ * The kinds of bounds that {@link Item#getBounds(matrix, options)} returns.
52
+ */
53
+ export type BoundsOptions = {
54
+ stroke?: boolean;
55
+ handle?: boolean;
56
+ shadow?: boolean;
57
+ internal?: boolean;
58
+ cacheItem?: Item;
59
+ transform?: {
60
+ matrix: Matrix;
61
+ item: Item;
62
+ };
63
+ };
64
+ /**
65
+ * The Item type allows you to access and modify the items in Paper.js
66
+ * projects. Its functionality is inherited by different project item types
67
+ * such as {@link Path}, {@link CompoundPath}, {@link Group}, {@link Layer} and
68
+ * {@link Raster}. They each add a layer of functionality that is unique to
69
+ * their type, but share the underlying properties and functions that they
70
+ * inherit from Item.
71
+ *
72
+ * Apps can define items of their own by extending these classes. A subclass
73
+ * passes the arguments of its constructor on to `super()`, as
74
+ * {@link #clone()} creates copies through it. Its state is best kept in
75
+ * {@link #data}, which copies, JSON and SVG carry along. Registering it with
76
+ * `registerClasses()` from `paper` gives it a name in JSON, so that
77
+ * importing creates it again, and SVG export writes it as the class it
78
+ * extends. Drawing handlers of the class, such as `Badge.onDraw`, draw all
79
+ * its items, see {@link Item.onDraw}.
80
+ *
81
+ * @example
82
+ * import { Path, registerClasses } from 'paper'
83
+ *
84
+ * class Badge extends Path {
85
+ * get label() {
86
+ * return this.data.label
87
+ * }
88
+ *
89
+ * set label(label) {
90
+ * this.data.label = label
91
+ * }
92
+ * }
93
+ * registerClasses({ Badge })
94
+ *
95
+ * var badge = new Badge({ segments: [[0, 0], [20, 0], [10, 15]] })
96
+ * badge.label = 'New'
97
+ * console.log(badge.clone().label) // 'New'
98
+ */
99
+ export declare class Item extends Emitter {
100
+ /**
101
+ * Two object constants that can be passed to the constructors of items to
102
+ * control insertion into the scene graph in a performative way.
103
+ *
104
+ * @private
105
+ */
106
+ static INSERT: {
107
+ insert: boolean;
108
+ };
109
+ static NO_INSERT: {
110
+ insert: boolean;
111
+ };
112
+ static _itemHandlers: string[];
113
+ static _drawCount: number;
114
+ _name: string | null | undefined;
115
+ _applyMatrix: boolean;
116
+ _canApplyMatrix: boolean;
117
+ _canScaleStroke: boolean;
118
+ _hasChildren: boolean;
119
+ _castsShadow: boolean;
120
+ _pivot: Point | null;
121
+ _visible: boolean;
122
+ _blendMode: BlendMode;
123
+ _opacity: number;
124
+ _locked: boolean;
125
+ _guide: boolean;
126
+ _textWrap: {
127
+ offset: number;
128
+ invert: boolean;
129
+ } | null;
130
+ _clipMask: boolean;
131
+ _selection: number;
132
+ _selectBounds: boolean;
133
+ _selectChildren: boolean;
134
+ _serializeFields: Record<string, any>;
135
+ _attributes: string[];
136
+ _prioritize: string[];
137
+ _boundsOptions: BoundsOptions;
138
+ _buffered: boolean;
139
+ _children: Item[];
140
+ _namedChildren: Record<string, Item[]>;
141
+ _id: number | null;
142
+ _parent: Item | null;
143
+ _index: number | null;
144
+ _project: Project;
145
+ _matrix: Matrix;
146
+ _style: Style;
147
+ _data?: Record<string, any> | null;
148
+ _bounds: Record<string, any> | undefined;
149
+ _position: Point | undefined;
150
+ _decomposed: ReturnType<Matrix['decompose']> | undefined;
151
+ _globalMatrix: Matrix | undefined;
152
+ _parentGlobalMatrix: Matrix | null | undefined;
153
+ _boundsCache?: {
154
+ ids: Record<number, Item>;
155
+ list: Item[];
156
+ };
157
+ _updateVersion?: number;
158
+ _symbol?: ItemDefinition | null;
159
+ _buffer: {
160
+ matrix?: Matrix | null;
161
+ version?: number;
162
+ bounds?: Rectangle;
163
+ canvas?: HTMLCanvasElement | OffscreenCanvas;
164
+ offset?: Point;
165
+ size?: Size;
166
+ } | null;
167
+ _shell: boolean;
168
+ _definition: SymbolDefinition;
169
+ _effects: EffectInstance[] | null;
170
+ _effectOutput: Item | null | undefined;
171
+ _effectVersion: number;
172
+ constructor(props?: any, point?: PointLike);
173
+ _initializeContent(project: Project): void;
174
+ _getCurrentStyle(project: Project): Style | null;
175
+ _serialize(options: JSONOptions, dictionary: JSONDictionary): any[];
176
+ /**
177
+ * Private notifier that is called whenever a change occurs in this item or
178
+ * its sub-elements, such as Segments, Curves, Styles, etc.
179
+ *
180
+ * @param flags describes what exactly has changed
181
+ */
182
+ _changed(flags: number): void;
183
+ _getChangeOwner(): Item;
184
+ /**
185
+ * Sets the properties of the passed object literal on this item to the
186
+ * values defined in the object literal, if the item has a property of the
187
+ * given name (or a setter defined for it).
188
+ *
189
+ * @param props the properties to set on the item
190
+ * @param exclude an object that can define any properties as `true` that
191
+ * should be excluded
192
+ * @return the item itself
193
+ * @chainable
194
+ *
195
+ * @example {@paperscript}
196
+ * // Setting properties through an object literal
197
+ * var circle = Path.circle({
198
+ * center: [80, 50],
199
+ * radius: 35
200
+ * });
201
+ *
202
+ * circle.set({
203
+ * strokeColor: 'red',
204
+ * strokeWidth: 10,
205
+ * fillColor: 'black',
206
+ * selected: true
207
+ * });
208
+ */
209
+ set(props: ItemProps<this>, exclude?: Record<string, boolean>): this;
210
+ /**
211
+ * Renders the item to a string, with its class name and its name, or its
212
+ * id if it has no name.
213
+ */
214
+ toString(): string;
215
+ /**
216
+ * The unique id of the item.
217
+ *
218
+ * @readonly
219
+ */
220
+ get id(): number;
221
+ /**
222
+ * The class name of the item as a string.
223
+ *
224
+ * @values 'Group', 'Layer', 'Path', 'CompoundPath', 'Shape', 'Raster',
225
+ * 'SymbolItem', 'PointText'
226
+ */
227
+ readonly className: string;
228
+ /**
229
+ * The name of the item. If the item has a name, it can be accessed by name
230
+ * through its parent's children list.
231
+ *
232
+ * @example {@paperscript}
233
+ * var path = Path.circle({
234
+ * center: [80, 50],
235
+ * radius: 35
236
+ * });
237
+
238
+ * // Set the name of the path:
239
+ * path.name = 'example';
240
+ *
241
+ * // Create a group and add path to it as a child:
242
+ * var group = new Group();
243
+ * group.addChild(path);
244
+ *
245
+ * // The path can be accessed by name:
246
+ * group.children['example'].fillColor = 'red';
247
+ */
248
+ get name(): string | null;
249
+ set name(name: string | null);
250
+ /**
251
+ * The path style of the item.
252
+ *
253
+ * Styles set on a {@link Group} or {@link Layer} are applied to the
254
+ * children that it contains at that moment. Items added to it later do not
255
+ * receive them.
256
+ *
257
+ * @example {@paperscript}
258
+ * // Applying several styles to an item in one go, by passing an object
259
+ * // to its style property:
260
+ * var circle = Path.circle({
261
+ * center: [80, 50],
262
+ * radius: 30
263
+ * });
264
+ * circle.style = {
265
+ * fillColor: 'blue',
266
+ * strokeColor: 'red',
267
+ * strokeWidth: 5
268
+ * };
269
+ *
270
+ * @example {@paperscript split=true height=100}
271
+ * // Copying the style of another item:
272
+ * var path = Path.circle({
273
+ * center: [50, 50],
274
+ * radius: 30,
275
+ * fillColor: 'red'
276
+ * });
277
+ *
278
+ * var path2 = Path.circle({
279
+ * center: new Point(180, 50),
280
+ * radius: 20
281
+ * });
282
+ *
283
+ * // Copy the path style of path:
284
+ * path2.style = path.style;
285
+ *
286
+ * @example {@paperscript}
287
+ * // Applying the same style object to multiple items:
288
+ * var myStyle = {
289
+ * fillColor: 'red',
290
+ * strokeColor: 'blue',
291
+ * strokeWidth: 4
292
+ * };
293
+ *
294
+ * var path = Path.circle({
295
+ * center: [50, 50],
296
+ * radius: 30
297
+ * });
298
+ * path.style = myStyle;
299
+ *
300
+ * var path2 = Path.circle({
301
+ * center: new Point(150, 50),
302
+ * radius: 20
303
+ * });
304
+ * path2.style = myStyle;
305
+ */
306
+ get style(): Style;
307
+ set style(style: Style | object);
308
+ _getStyleFields(): Record<string, any> | null;
309
+ _getStyleDefaults(): Record<string, any>;
310
+ _getStyles(style?: Style, key?: string, setting?: boolean): Style[] | null;
311
+ /**
312
+ * Specifies whether, and how, the item pushes aside the text of the
313
+ * {@link AreaText} items below it in its layer: `null`, or an object with
314
+ * `offset`, the space kept between them, and `invert`, to let the text
315
+ * flow inside it instead. `true` sets the defaults. It is the text wrap of
316
+ * Illustrator and InDesign; how the lines of a paragraph break, which CSS
317
+ * calls `text-wrap`, is {@link Style#lineWrap}.
318
+ *
319
+ * @default null
320
+ *
321
+ * @example
322
+ * var circle = Path.circle({ center: [100, 100], radius: 40 });
323
+ * circle.textWrap = { offset: 10 };
324
+ */
325
+ get textWrap(): {
326
+ offset: number;
327
+ invert: boolean;
328
+ } | null;
329
+ set textWrap(wrap: {
330
+ offset?: number;
331
+ invert?: boolean;
332
+ } | boolean | null);
333
+ /**
334
+ * The selection state of the item, a combination of the flags in
335
+ * `ItemSelection`.
336
+ *
337
+ * @private
338
+ */
339
+ get selection(): number;
340
+ set selection(selection: number);
341
+ _changeSelection(flag: number, selected: boolean): void;
342
+ /**
343
+ * Specifies whether the item is selected. This will also return `true` for
344
+ * {@link Group} items if they are partially selected, e.g. groups
345
+ * containing selected or partially selected paths.
346
+ *
347
+ * Paper.js draws the visual outlines of selected items on top of your
348
+ * project. This can be useful for debugging, as it allows you to see the
349
+ * construction of paths, position of path curves, individual segment points
350
+ * and bounding boxes of symbol and raster items.
351
+ *
352
+ * @default false
353
+ * @see Project#selectedItems
354
+ * @see Segment#selected
355
+ * @see Curve#selected
356
+ * @see SelectablePoint#selected
357
+ *
358
+ * @example {@paperscript}
359
+ * // Selecting an item:
360
+ * var path = Path.circle({
361
+ * center: [80, 50],
362
+ * radius: 35
363
+ * });
364
+ * path.selected = true; // Select the path
365
+ */
366
+ get selected(): boolean;
367
+ set selected(selected: boolean);
368
+ /**
369
+ * Specifies whether the item and all its descendants are selected. Setting
370
+ * it selects or deselects them all.
371
+ */
372
+ get fullySelected(): boolean;
373
+ set fullySelected(selected: boolean);
374
+ /**
375
+ * Specifies whether the item defines a clip mask. This can only be set on
376
+ * paths and compound paths, and only if the item is already contained
377
+ * within a clipping group.
378
+ *
379
+ * @default false
380
+ */
381
+ get clipMask(): boolean;
382
+ set clipMask(clipMask: boolean);
383
+ /**
384
+ * A plain javascript object which can be used to store
385
+ * arbitrary data on the item.
386
+ *
387
+ * @example
388
+ * var path = new Path();
389
+ * path.data.remember = 'milk';
390
+ *
391
+ * @example
392
+ * var path = new Path();
393
+ * path.data.malcolm = new Point(20, 30);
394
+ * console.log(path.data.malcolm.x); // 20
395
+ *
396
+ * @example
397
+ * var path = new Path();
398
+ * path.data = {
399
+ * home: 'Omicron Theta',
400
+ * found: 2338,
401
+ * pets: ['Spot']
402
+ * };
403
+ * console.log(path.data.pets.length); // 1
404
+ *
405
+ * @example
406
+ * var path = new Path({
407
+ * data: {
408
+ * home: 'Omicron Theta',
409
+ * found: 2338,
410
+ * pets: ['Spot']
411
+ * }
412
+ * });
413
+ * console.log(path.data.pets.length); // 1
414
+ */
415
+ get data(): Record<string, any>;
416
+ set data(data: Record<string, any>);
417
+ /**
418
+ * {@grouptitle Position and Bounding Boxes}
419
+ *
420
+ * The item's position within the parent item's coordinate system. By
421
+ * default, this is the {@link Rectangle#center} of the item's
422
+ * {@link #bounds} rectangle.
423
+ *
424
+ * @example {@paperscript}
425
+ * // Changing the position of a path:
426
+ *
427
+ * // Create a circle at position { x: 10, y: 10 }
428
+ * var circle = Path.circle({
429
+ * center: new Point(10, 10),
430
+ * radius: 10,
431
+ * fillColor: 'red'
432
+ * });
433
+ *
434
+ * // Move the circle to { x: 20, y: 20 }
435
+ * circle.position = new Point(20, 20);
436
+ *
437
+ * // Move the circle 100 points to the right and 50 points down
438
+ * circle.position += new Point(100, 50);
439
+ *
440
+ * @example {@paperscript split=true height=100}
441
+ * // Changing the x coordinate of an item's position:
442
+ *
443
+ * // Create a circle at position { x: 20, y: 20 }
444
+ * var circle = Path.circle({
445
+ * center: new Point(20, 20),
446
+ * radius: 10,
447
+ * fillColor: 'red'
448
+ * });
449
+ *
450
+ * // Move the circle 100 points to the right
451
+ * circle.position.x += 100;
452
+ */
453
+ get position(): SelectablePoint;
454
+ set position(point: PointLike);
455
+ /**
456
+ * Internal method used to calculate position either from pivot point or
457
+ * bounds.
458
+ *
459
+ * @param bounds if provided, these bounds are used instead of calling
460
+ * getBounds()
461
+ * @return the transformed pivot point or the center of the bounds
462
+ * @private
463
+ */
464
+ _getPositionFromBounds(bounds?: Rectangle): Point;
465
+ /**
466
+ * The item's pivot point, defining the point around which all
467
+ * transformations are hinging. This is also the reference point for
468
+ * {@link #position}. It is specified in the coordinate system of the item's
469
+ * parent, as {@link #position} and {@link #bounds} are, and moves along with
470
+ * the item as it is transformed. By default, it is set to `null`, meaning
471
+ * the {@link Rectangle#center} of the item's {@link #bounds} rectangle is
472
+ * used as pivot.
473
+ *
474
+ * @default null
475
+ */
476
+ get pivot(): Point | null;
477
+ set pivot(point: PointLike | null);
478
+ /**
479
+ * The bounding rectangle of the item excluding stroke width.
480
+ */
481
+ get bounds(): SelectableRectangle;
482
+ set bounds(rectangle: RectangleLike);
483
+ /**
484
+ * The bounding rectangle of the item including stroke width.
485
+ *
486
+ * Setting it fits the item's {@link #bounds} into the given rectangle minus
487
+ * the extent of the stroke on each side, also where this extent changes
488
+ * with the item's proportions, as with miters. A rectangle smaller than the
489
+ * stroke itself shrinks the bounds to its center.
490
+ */
491
+ get strokeBounds(): SelectableRectangle;
492
+ set strokeBounds(rectangle: RectangleLike);
493
+ /**
494
+ * Returns the bounding rectangle of the item, in the parent's coordinate
495
+ * space, of the kind that the options describe.
496
+ *
497
+ * @option [options.stroke=false] {Boolean} include the stroke width, as
498
+ * {@link #strokeBounds} does
499
+ * @option [options.handle=false] {Boolean} include the handles, as
500
+ * {@link #handleBounds} does
501
+ * @option [options.shadow=false] {Boolean} include the shadows of the
502
+ * item and its children
503
+ * @option [options.internal=false] {Boolean} leave out the item's own
504
+ * matrix, as {@link #internalBounds} does
505
+ *
506
+ * @param [options] the kind of bounds
507
+ * @return the bounds
508
+ */
509
+ getBounds(options?: BoundsOptions): Rectangle;
510
+ /**
511
+ * Returns the bounding rectangle of the item, transformed by the matrix
512
+ * instead of the item's own matrix, of the kind that the options describe.
513
+ * See {@link #getBounds(options)} for the options.
514
+ *
515
+ * @param matrix the matrix to transform the item's content by
516
+ * @param [options] the kind of bounds
517
+ * @return the bounds
518
+ */
519
+ getBounds(matrix: Matrix | null | undefined, options?: BoundsOptions): Rectangle;
520
+ /**
521
+ * Returns the bounding rectangle of the item including stroke width,
522
+ * transformed by the matrix instead of the item's own matrix.
523
+ *
524
+ * @param [matrix] the matrix to transform the item's content by
525
+ * @return the bounds
526
+ */
527
+ getStrokeBounds(matrix?: Matrix | null): Rectangle;
528
+ /**
529
+ * Protected method used in all the bounds getters. It loops through all the
530
+ * children, gets their bounds and finds the bounds around all of them.
531
+ * Subclasses override it to define calculations for the various required
532
+ * bounding types.
533
+ */
534
+ _getBounds(matrix: Matrix | null, options: BoundsOptions): Rectangle | {
535
+ rect: Rectangle;
536
+ nonscaling: boolean;
537
+ };
538
+ /**
539
+ * Private method that deals with the calling of _getBounds, recursive
540
+ * matrix concatenation and handles all the complicated caching mechanisms.
541
+ */
542
+ _getCachedBounds(matrix: Matrix | null, options: BoundsOptions, noInternal?: boolean): {
543
+ rect: Rectangle;
544
+ nonscaling: boolean;
545
+ };
546
+ /**
547
+ * Returns the bounds of the given items in project coordinates, as if
548
+ * they were grouped, without moving them, e.g. the bounds of the
549
+ * selection: `Item.getBounds(project.selectedItems)`. As in groups,
550
+ * items that aren't visible or are empty are left out.
551
+ *
552
+ * @option [options.stroke=false] {Boolean} include the stroke widths,
553
+ * as {@link Item#strokeBounds} does
554
+ * @option [options.handle=false] {Boolean} include the handles, as
555
+ * {@link Item#handleBounds} does
556
+ * @option [options.shadow=false] {Boolean} include the shadows of the
557
+ * items and their children
558
+ *
559
+ * @param items the items to get the bounds of
560
+ * @param [options] the kind of bounds
561
+ * @return the bounds of the items, empty if there are none
562
+ */
563
+ static getBounds(items: Item[], options?: BoundsOptions): Rectangle;
564
+ _decompose(): ReturnType<Matrix['decompose']> | null;
565
+ /**
566
+ * The current rotation angle of the item, as described by its
567
+ * {@link #matrix}.
568
+ * Please note that this only returns meaningful values for items with
569
+ * {@link #applyMatrix} set to `false`, meaning they do not directly bake
570
+ * transformations into their content.
571
+ */
572
+ get rotation(): number;
573
+ set rotation(rotation: number);
574
+ /**
575
+ * The current scale factor of the item, as described by its
576
+ * {@link #matrix}.
577
+ * Please note that this only returns meaningful values for items with
578
+ * {@link #applyMatrix} set to `false`, meaning they do not directly bake
579
+ * transformations into their content.
580
+ */
581
+ get scaling(): Point;
582
+ set scaling(scaling: PointLike | number);
583
+ /**
584
+ * The item's transformation matrix, defining position and dimensions in
585
+ * relation to its parent item in which it is contained.
586
+ */
587
+ get matrix(): Matrix;
588
+ set matrix(matrix: Matrix | number[]);
589
+ /**
590
+ * The item's global transformation matrix in relation to the global project
591
+ * coordinate space. Note that the view's transformations resulting from
592
+ * zooming and panning are not factored in.
593
+ */
594
+ get globalMatrix(): Matrix;
595
+ _getGlobalMatrix(_dontClone?: boolean): Matrix;
596
+ /**
597
+ * The item's global matrix in relation to the view coordinate space. This
598
+ * means that the view's transformations resulting from zooming and panning
599
+ * are factored in.
600
+ */
601
+ get viewMatrix(): Matrix;
602
+ /**
603
+ * Controls whether the transformations applied to the item (e.g. through
604
+ * {@link #transform(matrix)}, {@link #rotate(angle)},
605
+ * {@link #scale(scale)}, etc.) are stored in its {@link #matrix} property,
606
+ * or whether they are directly applied to its contents or children (passed
607
+ * on to the segments in {@link Path} items, the children of {@link Group}
608
+ * items, etc.).
609
+ *
610
+ * @default true
611
+ */
612
+ get applyMatrix(): boolean;
613
+ set applyMatrix(apply: boolean);
614
+ _matrixChanged(): void;
615
+ _bakeMatrix(recursively: boolean, setApplyMatrix?: boolean): boolean;
616
+ /**
617
+ * {@grouptitle Effects}
618
+ *
619
+ * The live effects of the item, in the order in which they apply, as the
620
+ * instances of the {@link Effect} effects that they use. They derive what is
621
+ * drawn from the item without changing it: drawing draws their output, and
622
+ * {@link #previewBounds} measures it, while hit testing, {@link #bounds} and
623
+ * {@link #strokeBounds} stay with the item itself. It is set to plain
624
+ * objects describing them, `{ type, parameters, visible }`, with the `type`
625
+ * of the effect. Changing the returned array directly isn't tracked, as with
626
+ * {@link Path#segments}.
627
+ *
628
+ * Paper.js has these effects, and {@link Effect} creates more:
629
+ *
630
+ * - `offset`: offsets the paths, see {@link PathItem#offset()}, with the
631
+ * parameters `distance` (`0`), `join` (`'miter'`) and `miterLimit`
632
+ * (`10`).
633
+ * - `outline`: outlines the strokes of the paths as filled areas next to
634
+ * their fills, see {@link PathItem#outline()}, following their
635
+ * {@link Path#strokeProfile}.
636
+ *
637
+ * @example {@paperscript}
638
+ * var path = Path.star({
639
+ * center: view.center,
640
+ * points: 5,
641
+ * radius1: 20,
642
+ * radius2: 40,
643
+ * strokeColor: 'black',
644
+ * strokeWidth: 8
645
+ * });
646
+ * path.effects = [
647
+ * { type: 'offset', parameters: { distance: 10, join: 'round' } },
648
+ * { type: 'outline' }
649
+ * ];
650
+ */
651
+ get effects(): EffectInstance[];
652
+ set effects(effects: EffectProps[] | null);
653
+ /**
654
+ * Adds an effect at the end of the item's effects.
655
+ *
656
+ * @param effect the plain object describing the effect
657
+ * @return the added instance
658
+ */
659
+ addEffect(effect: EffectProps): EffectInstance;
660
+ /**
661
+ * Inserts an effect into the item's effects at the given index.
662
+ *
663
+ * @param index the index at which to insert the effect
664
+ * @param effect the plain object describing the effect
665
+ * @return the inserted instance
666
+ */
667
+ insertEffect(index: number, effect: EffectProps): EffectInstance;
668
+ /**
669
+ * Inserts effects into the item's effects at the given index.
670
+ *
671
+ * @param index the index at which to insert the effects
672
+ * @param effects the plain objects describing the effects
673
+ * @return the inserted instances
674
+ */
675
+ insertEffects(index: number, effects: EffectProps[]): EffectInstance[];
676
+ /**
677
+ * Removes the effect at the given index from the item's effects.
678
+ *
679
+ * @param index the index of the effect to remove
680
+ * @return the removed instance, or `null`
681
+ */
682
+ removeEffect(index: number): EffectInstance | null;
683
+ /**
684
+ * Removes the effects from the start index to the end index from the item's
685
+ * effects, or all of them.
686
+ *
687
+ * @param [start=0] the index of the first effect to remove
688
+ * @param [end=effects.length] the index after the last one
689
+ * @return the removed instances
690
+ */
691
+ removeEffects(start?: number, end?: number): EffectInstance[];
692
+ _hasEffects(): boolean;
693
+ /**
694
+ * Returns what the item's visible effects make of it, in the item's own
695
+ * coordinates, outside of the scene graph, or `null` if it has none. It is
696
+ * kept until the item, its content, its effects or the registered effects
697
+ * change, so changing it isn't tracked.
698
+ *
699
+ * @return the output of the effects
700
+ */
701
+ getEffectOutput(): Item | null;
702
+ _applyEffects(art: Item): Item | null;
703
+ /**
704
+ * The bounds of what the item looks like with its effects and shadows, in
705
+ * the coordinate space of its parent: of their output with its strokes and
706
+ * shadows, or of its children's with their effects, and its stroke bounds
707
+ * and shadows without them, as Illustrator's "Use Preview Bounds".
708
+ */
709
+ get previewBounds(): Rectangle;
710
+ /**
711
+ * Returns the bounds of what the item looks like with its effects, as
712
+ * {@link #previewBounds}, in the coordinate space that the matrix maps to.
713
+ *
714
+ * @param matrix the matrix to transform the bounds with
715
+ */
716
+ getPreviewBounds(matrix?: Matrix | null): Rectangle;
717
+ /**
718
+ * {@grouptitle Project Hierarchy}
719
+ * The project that this item belongs to.
720
+ */
721
+ get project(): Project;
722
+ _setProject(project: Project, installEvents?: boolean): void;
723
+ /**
724
+ * The view that this item belongs to.
725
+ */
726
+ get view(): View;
727
+ /**
728
+ * The scope that this item belongs to, through its project.
729
+ */
730
+ get scope(): PaperScope;
731
+ _installEvents(install: boolean): void;
732
+ /**
733
+ * The layer that this item is contained within.
734
+ */
735
+ get layer(): Layer | null;
736
+ /**
737
+ * The item that this item is contained within.
738
+ *
739
+ * @example
740
+ * var path = new Path();
741
+ *
742
+ * // New items are placed in the active layer:
743
+ * console.log(path.parent == project.activeLayer); // true
744
+ *
745
+ * var group = new Group();
746
+ * group.addChild(path);
747
+ *
748
+ * // Now the parent of the path has become the group:
749
+ * console.log(path.parent == group); // true
750
+ *
751
+ * @example // Setting the parent of the item to another item
752
+ * var path = new Path();
753
+ *
754
+ * // New items are placed in the active layer:
755
+ * console.log(path.parent == project.activeLayer); // true
756
+ *
757
+ * var group = new Group();
758
+ * path.parent = group;
759
+ *
760
+ * // Now the parent of the path has become the group:
761
+ * console.log(path.parent == group); // true
762
+ *
763
+ * // The path is now contained in the children list of group:
764
+ * console.log(group.children[0] == path); // true
765
+ *
766
+ * @example // Setting the parent of an item in the constructor
767
+ * var group = new Group();
768
+ *
769
+ * var path = new Path({
770
+ * parent: group
771
+ * });
772
+ *
773
+ * // The parent of the path is the group:
774
+ * console.log(path.parent == group); // true
775
+ *
776
+ * // The path is contained in the children list of group:
777
+ * console.log(group.children[0] == path); // true
778
+ */
779
+ get parent(): Item | null;
780
+ set parent(item: Item);
781
+ /**
782
+ * Private helper to return the owner, either the parent, or the project
783
+ * for top-level layers. See Layer#_getOwner()
784
+ */
785
+ _getOwner(): Item | Project | null;
786
+ /**
787
+ * The children items contained within this item. Items that define a
788
+ * {@link #name} can also be accessed by name.
789
+ *
790
+ * Only {@link Group}, {@link Layer} and {@link CompoundPath} items can have
791
+ * children. On all other items, such as {@link Path}, {@link Shape},
792
+ * {@link Raster}, {@link SymbolItem} and {@link PointText}, `children` is
793
+ * `undefined`.
794
+ *
795
+ * <b>Please note:</b> The children array should not be modified directly
796
+ * using array functions. To remove single items from the children list, use
797
+ * {@link Item#remove()}, to remove all items from the children list, use
798
+ * {@link Item#removeChildren()}. To add items to the children list, use
799
+ * {@link Item#addChild(item)} or {@link Item#insertChild(index,item)}.
800
+ *
801
+ * @example {@paperscript}
802
+ * // Accessing items in the children array:
803
+ * var path = Path.circle({
804
+ * center: [80, 50],
805
+ * radius: 35
806
+ * });
807
+ *
808
+ * // Create a group and move the path into it:
809
+ * var group = new Group();
810
+ * group.addChild(path);
811
+ *
812
+ * // Access the path through the group's children array:
813
+ * group.children[0].fillColor = 'red';
814
+ *
815
+ * @example {@paperscript}
816
+ * // Accessing children by name:
817
+ * var path = Path.circle({
818
+ * center: [80, 50],
819
+ * radius: 35
820
+ * });
821
+ * // Set the name of the path:
822
+ * path.name = 'example';
823
+ *
824
+ * // Create a group and move the path into it:
825
+ * var group = new Group();
826
+ * group.addChild(path);
827
+ *
828
+ * // The path can be accessed by name:
829
+ * group.children['example'].fillColor = 'orange';
830
+ *
831
+ * @example {@paperscript}
832
+ * // Passing an array of items to item.children:
833
+ * var path = Path.circle({
834
+ * center: [80, 50],
835
+ * radius: 35
836
+ * });
837
+ *
838
+ * var group = new Group();
839
+ * group.children = [path];
840
+ *
841
+ * // The path is the first child of the group:
842
+ * group.firstChild.fillColor = 'green';
843
+ */
844
+ get children(): Item[] | null;
845
+ set children(items: Item[]);
846
+ /**
847
+ * The first item contained within this item. This is a shortcut for
848
+ * accessing `item.children[0]`.
849
+ */
850
+ get firstChild(): Item | null;
851
+ /**
852
+ * The last item contained within this item. This is a shortcut for
853
+ * accessing `item.children[item.children.length - 1]`.
854
+ */
855
+ get lastChild(): Item | null;
856
+ /**
857
+ * The next item on the same level as this item.
858
+ */
859
+ get nextSibling(): Item | null;
860
+ /**
861
+ * The previous item on the same level as this item.
862
+ */
863
+ get previousSibling(): Item | null;
864
+ /**
865
+ * The index of this item within the list of its parent's children.
866
+ */
867
+ get index(): number | null;
868
+ set index(index: number);
869
+ equals(item: Item): boolean;
870
+ /**
871
+ * A private helper for #equals(), to be overridden in sub-classes. When it
872
+ * is called, item is always defined, of the same class as `this` and has
873
+ * equal general state attributes such as matrix, style, opacity, etc.
874
+ */
875
+ _equals(item: any): boolean;
876
+ /**
877
+ * Clones the item within the same project and places the copy above the
878
+ * item.
879
+ *
880
+ * @option [options.insert=true] {Boolean} specifies whether the copy
881
+ * should be inserted into the scene graph. When set to `true`, it is
882
+ * inserted above the original
883
+ * @option [options.deep=true] {Boolean} specifies whether the item's
884
+ * children should also be cloned
885
+ *
886
+ * @param [options={ insert: true, deep: true }]
887
+ *
888
+ * @return the newly cloned item
889
+ * @chainable
890
+ *
891
+ * @example {@paperscript}
892
+ * // Cloning items:
893
+ * var circle = Path.circle({
894
+ * center: [50, 50],
895
+ * radius: 10,
896
+ * fillColor: 'red'
897
+ * });
898
+ *
899
+ * // Make 20 copies of the circle:
900
+ * for (var i = 0; i < 20; i++) {
901
+ * var copy = circle.clone();
902
+ *
903
+ * // Distribute the copies horizontally, so we can see them:
904
+ * copy.position.x += i * copy.bounds.width;
905
+ * }
906
+ */
907
+ clone(options?: {
908
+ insert?: boolean;
909
+ deep?: boolean;
910
+ } | boolean): this;
911
+ _clone(options?: {
912
+ insert?: boolean;
913
+ deep?: boolean;
914
+ } | boolean): this;
915
+ /**
916
+ * Copies the content of the specified item over to this item.
917
+ *
918
+ * @param source the item to copy the content from, of the same class as
919
+ * this item, as which subclasses read it
920
+ */
921
+ copyContent(source: this): void;
922
+ /**
923
+ * Copies all attributes of the specified item over to this item. This
924
+ * includes its style, visibility, matrix, pivot, blend-mode, opacity,
925
+ * selection state, data, name, etc.
926
+ *
927
+ * @param source the item to copy the attributes from
928
+ * @param excludeMatrix whether to exclude the transformation
929
+ * matrix when copying all attributes
930
+ */
931
+ copyAttributes(source: Item, excludeMatrix?: boolean): void;
932
+ _combineAppearance(item: Item): void;
933
+ /**
934
+ * Expands the item into plain items that draw the same, and replaces it
935
+ * with them, as Illustrator's Expand and Expand Appearance do: effects are
936
+ * applied, symbol items embedded, see {@link SymbolItem#embed()}, and
937
+ * shapes turned into paths, through all the item's descendants. Text and
938
+ * rasters stay as they are, as do gradients. Layers can't be replaced, so
939
+ * they keep their own effects, and expand their children.
940
+ *
941
+ * @option [options.strokes=false] {Boolean} whether to outline the strokes
942
+ * of paths as filled areas next to their fills, dashed strokes as their
943
+ * dashes, see {@link PathItem#outline()}
944
+ * @option [options.fills=false] {Boolean} whether to expand pattern fills
945
+ * into the pattern's tiles, clipped by their paths
946
+ *
947
+ * @param options the expand options
948
+ * @return the item that replaces the item, or the item itself if nothing
949
+ * replaces it. An item that has no parent isn't replaced, and the
950
+ * result isn't inserted
951
+ *
952
+ * @example {@paperscript}
953
+ * var path = Path.star({
954
+ * center: view.center,
955
+ * points: 5,
956
+ * radius1: 20,
957
+ * radius2: 40,
958
+ * fillColor: 'yellow',
959
+ * strokeColor: 'black',
960
+ * strokeWidth: 8,
961
+ * dashArray: [10, 4]
962
+ * });
963
+ * // Replace the path with its fill and the outlines of its dashes:
964
+ * var result = path.expand({ strokes: true });
965
+ * result.lastChild.selected = true;
966
+ */
967
+ expand(options?: ExpandOptions): Item;
968
+ /**
969
+ * Rasterizes the item into a newly created Raster object. The item itself
970
+ * is not removed after rasterization.
971
+ *
972
+ * @option [options.resolution=view.resolution] {Number} the desired
973
+ * resolution to be used when rasterizing, in pixels per inch (DPI). If
974
+ * not specified, the value of `view.resolution` is used by default.
975
+ * @option [options.raster=null] {Raster} specifies a raster to be reused
976
+ * when rasterizing. If the raster has the desired size already, then the
977
+ * underlying canvas is reused and no new memory needs to be allocated.
978
+ * If no raster is provided, a new raster item is created and returned
979
+ * instead.
980
+ * @option [options.insert=true] {Boolean} specifies whether the raster
981
+ * should be inserted into the scene graph. When set to `true`, it is
982
+ * inserted above the rasterized item.
983
+ *
984
+ * @param [options={}] the rasterization options
985
+ * @return the reused raster or the newly created raster item
986
+ *
987
+ * @example {@paperscript}
988
+ * // Rasterizing an item:
989
+ * var circle = Path.circle({
990
+ * center: [50, 50],
991
+ * radius: 5,
992
+ * fillColor: 'red'
993
+ * });
994
+ *
995
+ * // Create a rasterized version of the path:
996
+ * var raster = circle.rasterize();
997
+ *
998
+ * // Move it 100pt to the right:
999
+ * raster.position.x += 100;
1000
+ *
1001
+ * // Scale the path and the raster by 300%, so we can compare them:
1002
+ * circle.scale(5);
1003
+ * raster.scale(5);
1004
+ */
1005
+ rasterize(options?: {
1006
+ resolution?: number;
1007
+ raster?: Raster;
1008
+ insert?: boolean;
1009
+ }): Raster;
1010
+ /**
1011
+ * {@grouptitle Geometric Tests}
1012
+ *
1013
+ * Checks whether the item's geometry contains the given point.
1014
+ *
1015
+ * @example {@paperscript}
1016
+ * // Click within and outside the star below:
1017
+ *
1018
+ * // Create a star shaped path:
1019
+ * var path = Path.star({
1020
+ * center: [50, 50],
1021
+ * points: 12,
1022
+ * radius1: 20,
1023
+ * radius2: 40,
1024
+ * fillColor: 'black'
1025
+ * });
1026
+ *
1027
+ * // Whenever the user presses the mouse:
1028
+ * function onMouseDown(event) {
1029
+ * // If the position of the mouse is within the path,
1030
+ * // set its fill color to red, otherwise set it to
1031
+ * // black:
1032
+ * if (path.contains(event.point)) {
1033
+ * path.fillColor = 'red';
1034
+ * } else {
1035
+ * path.fillColor = 'black';
1036
+ * }
1037
+ * }
1038
+ *
1039
+ * @param point the point to check for
1040
+ */
1041
+ contains(point: PointLike | number, y?: number): boolean;
1042
+ _contains(point: Point): boolean;
1043
+ /**
1044
+ * Checks whether the item's bounds lie fully inside the given rectangle.
1045
+ *
1046
+ * @param rect the rectangle to check against
1047
+ * @return {@true if the item lies inside the rectangle}
1048
+ */
1049
+ isInside(rect: RectangleLike): boolean;
1050
+ _asPathItem(): PathItem;
1051
+ /**
1052
+ * Checks whether the item overlaps with the given item: whether their
1053
+ * outlines cross, or one contains the other, as
1054
+ * {@link Rectangle#intersects(rect)} does for rectangles. Items other than
1055
+ * paths and shapes are checked through their bounds. To only check whether
1056
+ * outlines cross, use {@link PathItem#getIntersections(path)}.
1057
+ *
1058
+ * @param item the item to check against
1059
+ * @return {@true if the items overlap}
1060
+ */
1061
+ intersects(item: Item, _matrix?: Matrix | null): boolean;
1062
+ /**
1063
+ * {@grouptitle Hit-testing, Fetching and Matching Items}
1064
+ *
1065
+ * Performs a hit-test on the item and its children (if it is a {@link
1066
+ * Group} or {@link Layer}) at the location of the specified point,
1067
+ * returning the first found hit.
1068
+ *
1069
+ * The options object allows you to control the specifics of the hit-test.
1070
+ * Without options, `fill`, `stroke` and `segments` are hit-tested. As soon
1071
+ * as an options object is passed, only the hit-tests that it sets to `true`
1072
+ * are performed. It may contain a combination of the following values:
1073
+ *
1074
+ * @option [options.tolerance={@link PaperScope#settings}.hitTolerance]
1075
+ * {Number} the tolerance of the hit-test, in project coordinates
1076
+ * @option options.class {Function} only hit-test against a specific item
1077
+ * class, or any of its sub-classes, by providing the constructor
1078
+ * function against which an `instanceof` check is performed:
1079
+ * {@values Group, Layer, Path, CompoundPath, Shape, Raster,
1080
+ * SymbolItem, PointText, ...}
1081
+ * @option options.match {Function} a match function to be called for each
1082
+ * found hit result: Return `true` to return the result, `false` to keep
1083
+ * searching
1084
+ * @option options.fill {Boolean} hit-test the fill of items
1085
+ * @option options.stroke {Boolean} hit-test the stroke of path items,
1086
+ * taking into account the setting of stroke color and width
1087
+ * @option options.segments {Boolean} hit-test for {@link Segment#point} of
1088
+ * {@link Path} items
1089
+ * @option options.curves {Boolean} hit-test the curves of path items,
1090
+ * without taking the stroke color or width into account
1091
+ * @option options.handles {Boolean} hit-test for the handles ({@link
1092
+ * Segment#handleIn} / {@link Segment#handleOut}) of path segments.
1093
+ * @option options.ends {Boolean} only hit-test for the first or last
1094
+ * segment points of open path items
1095
+ * @option options.position {Boolean} hit-test the {@link Item#position} of
1096
+ * items, which depends on the setting of {@link Item#pivot}
1097
+ * @option options.center {Boolean} hit-test the {@link Rectangle#center} of
1098
+ * the bounding rectangle of items ({@link Item#bounds})
1099
+ * @option options.bounds {Boolean} hit-test the corners and side-centers of
1100
+ * the bounding rectangle of items ({@link Item#bounds})
1101
+ * @option options.guides {Boolean} only hit-test items that have {@link
1102
+ * Item#guide} set to `true`
1103
+ * @option options.selected {Boolean} only hit selected items
1104
+ *
1105
+ * @param point the point where the hit-test should be performed
1106
+ * (in global coordinates system).
1107
+ * @param [options={ fill: true, stroke: true, segments: true,
1108
+ * tolerance: settings.hitTolerance }]
1109
+ * @return a hit result object describing what exactly was hit
1110
+ * or `null` if nothing was hit
1111
+ */
1112
+ hitTest(point: PointLike, options?: HitTestOptions): HitResult | null;
1113
+ /**
1114
+ * Performs a hit-test on the item and its children (if it is a {@link
1115
+ * Group} or {@link Layer}) at the location of the specified point,
1116
+ * returning all found hits.
1117
+ *
1118
+ * The options object allows you to control the specifics of the hit-
1119
+ * test. See {@link #hitTest(point[, options])} for a list of all options.
1120
+ *
1121
+ * @param point the point where the hit-test should be performed
1122
+ * (in global coordinates system).
1123
+ * @param [options={ fill: true, stroke: true, segments: true,
1124
+ * tolerance: settings.hitTolerance }]
1125
+ * @return hit result objects for all hits, describing what
1126
+ * exactly was hit, or an empty array if nothing was hit
1127
+ * @see #hitTest(point[, options])
1128
+ */
1129
+ hitTestAll(point: PointLike, options?: HitTestOptions): HitResult[];
1130
+ _hitTestChildren(point: Point, options: HitTestOptions, viewMatrix?: Matrix | null, _exclude?: Item | null): HitResult | null;
1131
+ _hitTest(point: Point, options: HitTestOptions, parentViewMatrix?: Matrix | null): HitResult | null;
1132
+ _hitTestSelf(point: Point, options: HitTestOptions, _viewMatrix?: Matrix | null, _strokeMatrix?: Matrix | null): HitResult | HitResult[] | null;
1133
+ /**
1134
+ * Checks whether the item matches the criteria described by the given
1135
+ * object, by iterating over all of its properties and matching against
1136
+ * their values through {@link #matches(name, compare)}.
1137
+ *
1138
+ * See {@link Project#getItems(options)} for a selection of illustrated
1139
+ * examples.
1140
+ *
1141
+ * @param options the criteria to match against
1142
+ * @return {@true if the item matches all the criteria}
1143
+ * @see #getItems(options)
1144
+ */
1145
+ matches(options: MatchOptions | ((item: Item) => boolean)): boolean;
1146
+ /**
1147
+ * Checks whether the item matches the given criteria. Extended matching is
1148
+ * possible by providing a compare function or a regular expression.
1149
+ * Matching points, colors only work as a comparison of the full object, not
1150
+ * partial matching (e.g. only providing the x-coordinate to match all
1151
+ * points with that x-value). Partial matching does work for
1152
+ * {@link Item#data}.
1153
+ *
1154
+ * See {@link Project#getItems(options)} for a selection of illustrated
1155
+ * examples.
1156
+ *
1157
+ * @param name the name of the state to match against
1158
+ * @param compare the value, function or regular expression to
1159
+ * compare against
1160
+ * @return {@true if the item matches the state}
1161
+ * @see #getItems(options)
1162
+ */
1163
+ matches(name: string, compare: unknown): boolean;
1164
+ /**
1165
+ * Fetch the descendants (children or children of children) of this item
1166
+ * that match the properties in the specified object. Extended matching is
1167
+ * possible by providing a compare function or regular expression. Matching
1168
+ * points, colors only work as a comparison of the full object, not partial
1169
+ * matching (e.g. only providing the x-coordinate to match all points with
1170
+ * that x-value). Partial matching does work for {@link Item#data}.
1171
+ *
1172
+ * Matching items against a rectangular area is also possible, by setting
1173
+ * either `options.inside` or `options.overlapping` to a rectangle
1174
+ * describing the area in which the items either have to be fully or partly
1175
+ * contained.
1176
+ *
1177
+ * See {@link Project#getItems(options)} for a selection of illustrated
1178
+ * examples.
1179
+ *
1180
+ * @option [options.recursive=true] {Boolean} whether to loop recursively
1181
+ * through all children, or stop at the current level
1182
+ * @option options.match {Function} a match function to be called for each
1183
+ * item, allowing the definition of more flexible item checks that are
1184
+ * not bound to properties. If no other match properties are defined,
1185
+ * this function can also be passed instead of the `options` object
1186
+ * @option options.class {Function} the constructor function of the item
1187
+ * type to match against
1188
+ * @option options.inside {Rectangle} the rectangle in which the items need
1189
+ * to be fully contained
1190
+ * @option options.overlapping {Rectangle} the rectangle with which the
1191
+ * items need to at least partly overlap
1192
+ *
1193
+ * @param options the criteria to match against
1194
+ * @return the list of matching descendant items, in their
1195
+ * stacking order from bottom to top, with each item listed before its
1196
+ * own descendants
1197
+ * @see #matches(options)
1198
+ */
1199
+ getItems(options: MatchOptions | ((item: Item) => boolean)): Item[];
1200
+ /**
1201
+ * Fetch the first descendant (child or child of child) of this item
1202
+ * that matches the properties in the specified object.
1203
+ * Extended matching is possible by providing a compare function or
1204
+ * regular expression. Matching points, colors only work as a comparison
1205
+ * of the full object, not partial matching (e.g. only providing the
1206
+ * x-coordinate to match all points with that x-value). Partial matching
1207
+ * does work for {@link Item#data}.
1208
+ * See {@link Project#getItems(options)} for a selection of illustrated
1209
+ * examples.
1210
+ *
1211
+ * @param options the criteria to match against
1212
+ * @return the first descendant item matching the given criteria
1213
+ * @see #getItems(options)
1214
+ */
1215
+ getItem(options: MatchOptions | ((item: Item) => boolean)): Item | null;
1216
+ /**
1217
+ * Imports (deserializes) the stored JSON data into this item. If the data
1218
+ * describes an item of the same class or a parent class of the item, the
1219
+ * data is imported into the item itself. If not, the imported item is added
1220
+ * to this item's {@link Item#children} list. Note that not all type of
1221
+ * items can have children. In hosted projects, references to the
1222
+ * definitions of the host import as these definitions, see
1223
+ * {@link Project#host}.
1224
+ *
1225
+ * @param json the JSON data to import from
1226
+ */
1227
+ importJSON(json: string | unknown[]): Item | null;
1228
+ /**
1229
+ * Exports the item with its content and child items as an SVG DOM. With
1230
+ * `options.bounds` or `options.matrix`, the item is wrapped in an `<svg>`
1231
+ * element sized to the bounds, as {@link Project#exportSVG(options)} does.
1232
+ *
1233
+ * @option [options.bounds] {String|Rectangle} the bounds of the area to
1234
+ * export, either as a string ({@values 'view', 'content'}), or a
1235
+ * {@link Rectangle} object: `'view'` uses the view bounds,
1236
+ * `'content'` uses the stroke bounds of the item
1237
+ * @option [options.matrix] {Matrix} the matrix with which to transform the
1238
+ * exported content: If `options.bounds` is set to `'view'`,
1239
+ * `paper.view.matrix` is used, for all other settings of
1240
+ * `options.bounds` the identity matrix is used.
1241
+ * @option [options.asString=false] {Boolean} whether a SVG node or a
1242
+ * `String` is to be returned
1243
+ * @option [options.precision=5] {Number} the amount of fractional digits in
1244
+ * numbers used in SVG data
1245
+ * @option [options.matchShapes=false] {Boolean} whether path items should
1246
+ * be converted to SVG shape items (rect, circle, ellipse,
1247
+ * line, polyline, polygon), if their geometries match
1248
+ * @option [options.embedImages=true] {Boolean} whether raster images should
1249
+ * be embedded as base64 data inlined in the xlink:href attribute, or
1250
+ * kept as a link to their external URL.
1251
+ * @option [options.reuseImages=false] {Boolean} whether raster images with
1252
+ * the same content should only be exported once into the `<defs>`
1253
+ * element, and placed through `<use>` elements referencing it
1254
+ * @option [options.idPrefix=''] {String} a prefix for the ids generated
1255
+ * for definitions such as gradients, clip paths and symbols, to keep
1256
+ * them unique when several exported SVGs are placed in one document
1257
+ * @option [options.reduceAttributes=true] {Boolean} whether to only include
1258
+ * style attributes in the SVG output that differ from their parents,
1259
+ * or to always include them (much faster but leading to redundancies).
1260
+ * @option [options.processNode] {Function} the function to process the
1261
+ * SVG node made for each exported item, receiving an object with the
1262
+ * `item` and its `node`: It can change the node, e.g. to add attributes
1263
+ * that Paper.js doesn't export, or return a node to replace it with. It
1264
+ * is called before the item's name, style, visibility and data are set
1265
+ * on the node, which replace attributes of the same names.
1266
+ *
1267
+ * @param [options] the export options
1268
+ * @return the item converted to an SVG node or a `String`, depending on
1269
+ * `options.asString`
1270
+ */
1271
+ exportSVG(options?: SVGExportOptions): SVGElement | string;
1272
+ /**
1273
+ * Converts the provided SVG content into Paper.js items and adds them to
1274
+ * this item's children list. Note that the item is not cleared first.
1275
+ * You can call {@link Item#removeChildren()} to do so.
1276
+ *
1277
+ * `<symbol>` elements are imported as {@link SymbolDefinition} items, and
1278
+ * the `<use>` elements that place them as {@link SymbolItem} items. The
1279
+ * styles that `<use>` elements inherit don't reach the symbols' content.
1280
+ *
1281
+ * The layers in SVG content that Paper.js exported come back as
1282
+ * {@link Layer} items inside the imported group. To make them the layers
1283
+ * of a project again, import the content with
1284
+ * {@link Project#importSVG(svg)}.
1285
+ *
1286
+ * To load SVG from a URL or a file, see {@link #loadSVG(source)}.
1287
+ *
1288
+ * @option [options.expandShapes=false] {Boolean} whether imported shape
1289
+ * items should be expanded to path items
1290
+ * @option [options.crossOrigin] {String} the {@link Raster#crossOrigin}
1291
+ * value of the rasters created for `<image>` elements, to load their
1292
+ * images with CORS
1293
+ * @option [options.insert=true] {Boolean} whether the imported items should
1294
+ * be added to the item that `importSVG()` is called on
1295
+ * @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
1296
+ * {Boolean} whether the imported items should have their transformation
1297
+ * matrices applied to their contents or not
1298
+ * @option [options.processItem] {Function} the function to process the
1299
+ * item made for each imported SVG element, receiving an object with
1300
+ * the `item` and its `node`: It can read attributes that Paper.js
1301
+ * doesn't import, or return an item to replace it with. It is called
1302
+ * after the element's attributes and data are applied to the item, so
1303
+ * it can extend `item.data`. A replacement item doesn't receive them:
1304
+ * copy them over from `item` as needed.
1305
+ *
1306
+ * @param svg the SVG content to import, either as a SVG DOM node, a string
1307
+ * containing SVG content, or the id of an SVG element in the document
1308
+ * @param [options] the import options
1309
+ * @return the newly created Paper.js item containing the converted
1310
+ * SVG content
1311
+ */
1312
+ importSVG(svg: SVGElement | string, options?: SVGImportOptions): Item | null;
1313
+ /**
1314
+ * Loads SVG from a URL or a file, and imports it as
1315
+ * {@link #importSVG(svg)} does, with the same options.
1316
+ *
1317
+ * URLs are fetched as they are, so validate URLs that come from untrusted
1318
+ * sources first, especially on servers, where they could reach internal
1319
+ * addresses.
1320
+ *
1321
+ * @param source the URL of the SVG file to fetch, or a `File` to read,
1322
+ * e.g. from a file input
1323
+ * @param [options] the import options, see {@link #importSVG(svg)}
1324
+ * @return a promise of the imported item
1325
+ */
1326
+ loadSVG(source: string | File, options?: SVGImportOptions): Promise<Item | null>;
1327
+ /**
1328
+ * {@grouptitle Hierarchy Operations}
1329
+ *
1330
+ * Adds the specified item as a child of this item at the end of its
1331
+ * {@link #children} list. You can use this function for groups, compound
1332
+ * paths and layers.
1333
+ *
1334
+ * @param item the item to be added as a child
1335
+ * @return the added item, or `null` if adding was not possible
1336
+ */
1337
+ addChild(item: Item): Item | null;
1338
+ /**
1339
+ * Inserts the specified item as a child of this item at the specified index
1340
+ * in its {@link #children} list. You can use this function for groups,
1341
+ * compound paths and layers.
1342
+ *
1343
+ * @param index the index at which to insert the item
1344
+ * @param item the item to be inserted as a child
1345
+ * @return the inserted item, or `null` if inserting was not possible
1346
+ */
1347
+ insertChild(index: number | undefined, item: Item): Item | null;
1348
+ /**
1349
+ * Adds the specified items as children of this item at the end of its
1350
+ * children list. You can use this function for groups, compound paths and
1351
+ * layers.
1352
+ *
1353
+ * @param items the items to be added as children
1354
+ * @return the added items, or `null` if adding was not possible
1355
+ */
1356
+ addChildren(items: Item[]): Item[] | null;
1357
+ /**
1358
+ * Inserts the specified items as children of this item at the specified
1359
+ * index in its {@link #children} list. You can use this function for
1360
+ * groups, compound paths and layers.
1361
+ *
1362
+ * @param index the index at which to insert the items
1363
+ * @param items the items to be inserted as children
1364
+ * @return the inserted items, or `null` if inserting was not
1365
+ * possible
1366
+ */
1367
+ insertChildren(index: number | undefined, items: Item[]): Item[] | null;
1368
+ _insertChildren(index: number | undefined, items: Item[]): Item[] | null;
1369
+ _insertItem(index: number | undefined, item: Item, _created?: boolean): Item | null;
1370
+ /**
1371
+ * Private helper method used by {@link #insertAbove(item)} and
1372
+ * {@link #insertBelow(item)}, to insert this item in relation to a
1373
+ * specified other item.
1374
+ *
1375
+ * @param item the item in relation to which which it should be
1376
+ * inserted
1377
+ * @param offset the offset at which the item should be inserted
1378
+ * @return the inserted item, or `null` if inserting was not possible
1379
+ */
1380
+ _insertAt(item: Item, offset: number): this | null;
1381
+ /**
1382
+ * Inserts this item above the specified item.
1383
+ *
1384
+ * @param item the item above which it should be inserted
1385
+ * @return the inserted item, or `null` if inserting was not possible
1386
+ */
1387
+ insertAbove(item: Item): this | null;
1388
+ /**
1389
+ * Inserts this item below the specified item.
1390
+ *
1391
+ * @param item the item below which it should be inserted
1392
+ * @return the inserted item, or `null` if inserting was not possible
1393
+ */
1394
+ insertBelow(item: Item): this | null;
1395
+ /**
1396
+ * Sends this item to the back of all other items within the same parent.
1397
+ */
1398
+ sendToBack(): Item | null;
1399
+ /**
1400
+ * Brings this item to the front of all other items within the same parent.
1401
+ */
1402
+ bringToFront(): Item | null;
1403
+ /**
1404
+ * Adds it to the specified owner, which can be either an {@link Item} or a
1405
+ * {@link Project}.
1406
+ *
1407
+ * @param owner the item or project to
1408
+ * add the item to
1409
+ * @return the item itself, if it was successfully added
1410
+ * @chainable
1411
+ */
1412
+ addTo(owner: Item | Project): this;
1413
+ /**
1414
+ * Clones the item and adds it to the specified owner, which can be either
1415
+ * an {@link Item} or a {@link Project}.
1416
+ *
1417
+ * @param owner the item or project to
1418
+ * copy the item to
1419
+ * @return the new copy of the item, if it was successfully added
1420
+ * @chainable
1421
+ */
1422
+ copyTo(owner: Item | Project): this;
1423
+ /**
1424
+ * If this is a group, layer or compound-path with only one child-item,
1425
+ * the child-item is moved outside and the parent is erased. Otherwise, the
1426
+ * item itself is returned unmodified.
1427
+ *
1428
+ * @param [options] the options passed on to {@link
1429
+ * Path#reduce(options)}
1430
+ * @return the reduced item
1431
+ */
1432
+ reduce(options?: {
1433
+ simplify?: boolean;
1434
+ }): Item;
1435
+ /**
1436
+ * Removes the item from its parent's named children list.
1437
+ */
1438
+ _removeNamed(): void;
1439
+ /**
1440
+ * Removes the item from its parent's children list.
1441
+ */
1442
+ _remove(notifySelf: boolean, notifyParent: boolean): boolean;
1443
+ /**
1444
+ * Removes the item and all its children from the project. The item is not
1445
+ * destroyed and can be inserted again after removal.
1446
+ *
1447
+ * @return {@true if the item was removed}
1448
+ */
1449
+ remove(): boolean;
1450
+ /**
1451
+ * Replaces this item with the provided new items which will take its place
1452
+ * in the project hierarchy instead, in the given order. This also ungroups
1453
+ * a group, e.g. `group.replaceWith(...group.children)`, but note that the
1454
+ * items keep their own matrices, see {@link Group#ungroup()}.
1455
+ *
1456
+ * @param items the items that will replace this item
1457
+ * @return {@true if the item was replaced}
1458
+ */
1459
+ replaceWith(...items: Item[]): boolean;
1460
+ /**
1461
+ * Removes all of the item's {@link #children} (if any).
1462
+ *
1463
+ * @return an array containing the removed items
1464
+ */
1465
+ removeChildren(): Item[] | null;
1466
+ /**
1467
+ * Removes the children from the specified `start` index to and excluding
1468
+ * the `end` index from the parent's {@link #children} array.
1469
+ *
1470
+ * @param start the beginning index, inclusive
1471
+ * @param [end=children.length] the ending index, exclusive
1472
+ * @return an array containing the removed items
1473
+ */
1474
+ removeChildren(start: number, end?: number): Item[] | null;
1475
+ /**
1476
+ * Removes all of the item's {@link #children} (if any), as
1477
+ * {@link #removeChildren()} does.
1478
+ *
1479
+ * @return an array containing the removed items
1480
+ */
1481
+ clear(): unknown[] | null | undefined;
1482
+ /**
1483
+ * Reverses the order of the item's children.
1484
+ */
1485
+ reverseChildren(): void;
1486
+ /**
1487
+ * {@grouptitle Tests}
1488
+ * Specifies whether the item has any content or not. The meaning of what
1489
+ * content is differs from type to type. For example, a {@link Group} with
1490
+ * no children, a {@link TextItem} with no text content and a {@link Path}
1491
+ * with no segments all are considered empty.
1492
+ *
1493
+ * @param [recursively=false] whether an item with children should be
1494
+ * considered empty if all its descendants are empty
1495
+ */
1496
+ isEmpty(recursively?: boolean): boolean;
1497
+ /**
1498
+ * Checks whether the item is editable.
1499
+ *
1500
+ * @return {@true when neither the item, nor its parents are
1501
+ * locked or hidden}
1502
+ */
1503
+ isEditable(): boolean;
1504
+ /**
1505
+ * {@grouptitle Style Tests}
1506
+ *
1507
+ * Checks whether the item has a visible fill, a fill color with an alpha
1508
+ * above 0. Hit-tests also hit transparent fills, see {@link #hitTest}.
1509
+ *
1510
+ * @return {@true if the item has a visible fill}
1511
+ */
1512
+ hasFill(): boolean;
1513
+ /**
1514
+ * Checks whether the item has a stroke.
1515
+ *
1516
+ * @return {@true if the item has a stroke}
1517
+ */
1518
+ hasStroke(): boolean;
1519
+ /**
1520
+ * Checks whether the item has a shadow.
1521
+ *
1522
+ * @return {@true if the item has a shadow}
1523
+ */
1524
+ hasShadow(): boolean;
1525
+ /**
1526
+ * Returns -1 if 'this' is above 'item', 1 if below, 0 if their order is not
1527
+ * defined in such a way, e.g. if one is a descendant of the other.
1528
+ */
1529
+ _getOrder(item: Item): number;
1530
+ /**
1531
+ * {@grouptitle Hierarchy Tests}
1532
+ *
1533
+ * Checks if the item contains any children items.
1534
+ *
1535
+ * @return {@true if it has one or more children}
1536
+ */
1537
+ hasChildren(): boolean;
1538
+ /**
1539
+ * Checks whether the item and all its parents are inserted into scene graph
1540
+ * or not.
1541
+ *
1542
+ * @return {@true if the item is inserted into the scene graph}
1543
+ */
1544
+ isInserted(): boolean;
1545
+ /**
1546
+ * Checks if this item is above the specified item in the stacking order
1547
+ * of the project. If one item is a descendant of the other, neither is
1548
+ * above the other and `false` is returned.
1549
+ *
1550
+ * @param item the item to check against
1551
+ * @return {@true if it is above the specified item}
1552
+ */
1553
+ isAbove(item: Item): boolean;
1554
+ /**
1555
+ * Checks if the item is below the specified item in the stacking order of
1556
+ * the project. If one item is a descendant of the other, neither is below
1557
+ * the other and `false` is returned.
1558
+ *
1559
+ * @param item the item to check against
1560
+ * @return {@true if it is below the specified item}
1561
+ */
1562
+ isBelow(item: Item): boolean;
1563
+ /**
1564
+ * Checks whether the specified item is the parent of the item.
1565
+ *
1566
+ * @param item the item to check against
1567
+ * @return {@true if it is the parent of the item}
1568
+ */
1569
+ isParent(item: Item): boolean;
1570
+ /**
1571
+ * Checks whether the specified item is a child of the item.
1572
+ *
1573
+ * @param item the item to check against
1574
+ * @return {@true if it is a child of the item}
1575
+ */
1576
+ isChild(item: Item): boolean;
1577
+ /**
1578
+ * Checks if the item is contained within the specified item.
1579
+ *
1580
+ * @param item the item to check against
1581
+ * @return {@true if it is inside the specified item}
1582
+ */
1583
+ isDescendant(item: Item | null): boolean;
1584
+ /**
1585
+ * Checks if the item is an ancestor of the specified item.
1586
+ *
1587
+ * @param item the item to check against
1588
+ * @return {@true if the item is an ancestor of the specified
1589
+ * item}
1590
+ */
1591
+ isAncestor(item: Item): boolean;
1592
+ /**
1593
+ * Checks if the item is a sibling of the specified item.
1594
+ *
1595
+ * @param item the item to check against
1596
+ * @return {@true if the item is a sibling of the specified item}
1597
+ */
1598
+ isSibling(item: Item): boolean;
1599
+ /**
1600
+ * Checks whether the item is grouped with the specified item.
1601
+ *
1602
+ * @param item the item to check against
1603
+ * @return {@true if the items are grouped together}
1604
+ */
1605
+ isGroupedWith(item: Item): boolean;
1606
+ /**
1607
+ * {@grouptitle Transform Functions}
1608
+ *
1609
+ * Translates (moves) the item by the given offset.
1610
+ *
1611
+ * @param delta the offset to translate the item by, or one distance for
1612
+ * both directions
1613
+ */
1614
+ translate(delta: PointLike | number, y?: number): this;
1615
+ /**
1616
+ * Transforms the item by the given matrix.
1617
+ *
1618
+ * Items that apply the matrix to their content, see {@link #applyMatrix},
1619
+ * keep the width of their strokes, unless `options.strokes` is set. Items
1620
+ * that keep their matrix draw all their content through it, so their
1621
+ * strokes scale along, unless {@link #strokeScaling} is `false`.
1622
+ *
1623
+ * @param matrix the matrix by which the item shall be transformed
1624
+ * @param [options] controls what the transformation includes
1625
+ * @option [options.strokes=false] {Boolean} whether to scale the
1626
+ * {@link #strokeWidth}, {@link #dashArray} and {@link #dashOffset} of
1627
+ * the paths that the matrix is applied to, by the geometric mean of
1628
+ * its scale factors
1629
+ * @option [options.gradients=true] {Boolean} whether gradient colors
1630
+ * transform along with the item, or stay where they are
1631
+ * @option [options.patterns=true] {Boolean} whether the tiles of pattern
1632
+ * colors transform along with the item, or stay where they are
1633
+ *
1634
+ * @example
1635
+ * // Scale a path along with its stroke:
1636
+ * path.transform(new Matrix().scale(2, path.position), { strokes: true });
1637
+ */
1638
+ transform(matrix: Matrix, options?: TransformOptions): this;
1639
+ _transformContent(matrix: Matrix, options?: InternalTransformOptions): boolean;
1640
+ /**
1641
+ * Converts the specified point from global project coordinate space to the
1642
+ * item's own local coordinate space.
1643
+ *
1644
+ * @param point the point to be transformed
1645
+ * @return the transformed point as a new instance
1646
+ */
1647
+ globalToLocal(point: PointLike | number, y?: number): Point;
1648
+ /**
1649
+ * Converts the specified point from the item's own local coordinate space
1650
+ * to the global project coordinate space.
1651
+ *
1652
+ * @param point the point to be transformed
1653
+ * @return the transformed point as a new instance
1654
+ */
1655
+ localToGlobal(point: PointLike | number, y?: number): Point;
1656
+ /**
1657
+ * Converts the specified point from the parent's coordinate space to
1658
+ * item's own local coordinate space.
1659
+ *
1660
+ * @param point the point to be transformed
1661
+ * @return the transformed point as a new instance
1662
+ */
1663
+ parentToLocal(point: PointLike | number, y?: number): Point;
1664
+ /**
1665
+ * Converts the specified point from the item's own local coordinate space
1666
+ * to the parent's coordinate space.
1667
+ *
1668
+ * @param point the point to be transformed
1669
+ * @return the transformed point as a new instance
1670
+ */
1671
+ localToParent(point: PointLike | number, y?: number): Point;
1672
+ /**
1673
+ * Transform the item so that its {@link #bounds} are centered in the
1674
+ * specified rectangle and fitted to it as described by `fit`.
1675
+ *
1676
+ * @param rectangle the rectangle to fit the item into
1677
+ * @param [fit='contain'] how to fit the item, as in CSS's
1678
+ * `object-fit`: `'contain'` fits all of it within the rectangle,
1679
+ * `'cover'` makes it cover the whole rectangle, and `'fill'` stretches
1680
+ * it to the rectangle, changing its aspect ratio
1681
+ *
1682
+ * @example {@paperscript height=100}
1683
+ * // Fitting an item to the bounding rectangle of another item's bounding
1684
+ * // rectangle:
1685
+ *
1686
+ * // Create a rectangle shaped path with its top left corner
1687
+ * // at {x: 80, y: 25} and a size of {width: 75, height: 50}:
1688
+ * var path = Path.rectangle({
1689
+ * point: [80, 25],
1690
+ * size: [75, 50],
1691
+ * fillColor: 'black'
1692
+ * });
1693
+ *
1694
+ * // Create a circle shaped path with its center at {x: 80, y: 50}
1695
+ * // and a radius of 30.
1696
+ * var circlePath = Path.circle({
1697
+ * center: [80, 50],
1698
+ * radius: 30,
1699
+ * fillColor: 'red'
1700
+ * });
1701
+ *
1702
+ * // Fit the circlePath to the bounding rectangle of
1703
+ * // the rectangular path:
1704
+ * circlePath.fitBounds(path.bounds);
1705
+ *
1706
+ * @example {@paperscript height=100}
1707
+ * // Fitting an item to the bounding rectangle of another item's bounding
1708
+ * // rectangle, covering all of it:
1709
+ *
1710
+ * // Create a rectangle shaped path with its top left corner
1711
+ * // at {x: 80, y: 25} and a size of {width: 75, height: 50}:
1712
+ * var path = Path.rectangle({
1713
+ * point: [80, 25],
1714
+ * size: [75, 50],
1715
+ * fillColor: 'black'
1716
+ * });
1717
+ *
1718
+ * // Create a circle shaped path with its center at {x: 80, y: 50}
1719
+ * // and a radius of 30.
1720
+ * var circlePath = Path.circle({
1721
+ * center: [80, 50],
1722
+ * radius: 30,
1723
+ * fillColor: 'red'
1724
+ * });
1725
+ *
1726
+ * // Fit the circlePath to the bounding rectangle of
1727
+ * // the rectangular path:
1728
+ * circlePath.fitBounds(path.bounds, 'cover');
1729
+ *
1730
+ * @example {@paperscript height=200}
1731
+ * // Fitting an item to the bounding rectangle of the view
1732
+ * var path = Path.circle({
1733
+ * center: [80, 50],
1734
+ * radius: 30,
1735
+ * fillColor: 'red'
1736
+ * });
1737
+ *
1738
+ * // Fit the path to the bounding rectangle of the view:
1739
+ * path.fitBounds(view.bounds);
1740
+ */
1741
+ fitBounds(rectangle: RectangleLike, fit?: 'contain' | 'cover' | 'fill'): void;
1742
+ _canComposite(): boolean;
1743
+ /**
1744
+ * {@grouptitle Remove On Event}
1745
+ *
1746
+ * Removes the item when the events specified in the passed options object
1747
+ * occur.
1748
+ *
1749
+ * @option options.move {Boolean} remove the item when the next {@link
1750
+ * Tool#onMouseMove} event is fired.
1751
+ *
1752
+ * @option options.drag {Boolean} remove the item when the next {@link
1753
+ * Tool#onMouseDrag} event is fired.
1754
+ *
1755
+ * @option options.down {Boolean} remove the item when the next {@link
1756
+ * Tool#onMouseDown} event is fired.
1757
+ *
1758
+ * @option options.up {Boolean} remove the item when the next {@link
1759
+ * Tool#onMouseUp} event is fired.
1760
+ *
1761
+ * @param options the events to remove the item on
1762
+ *
1763
+ * @example {@paperscript height=200}
1764
+ * // Click and drag below:
1765
+ * function onMouseDrag(event) {
1766
+ * // Create a circle shaped path at the mouse position,
1767
+ * // with a radius of 10:
1768
+ * var path = Path.circle({
1769
+ * center: event.point,
1770
+ * radius: 10,
1771
+ * fillColor: 'black'
1772
+ * });
1773
+ *
1774
+ * // Remove the path on the next onMouseDrag or onMouseDown event:
1775
+ * path.removeOn({
1776
+ * drag: true,
1777
+ * down: true
1778
+ * });
1779
+ * }
1780
+ */
1781
+ removeOn(options: {
1782
+ move?: boolean;
1783
+ drag?: boolean;
1784
+ down?: boolean;
1785
+ up?: boolean;
1786
+ }): this;
1787
+ /**
1788
+ * {@grouptitle Tweening Functions}
1789
+ *
1790
+ * Tween item between two states.
1791
+ *
1792
+ * @option options.duration {Number} the duration of the tweening
1793
+ * @option [options.easing='linear'] {Function|String} an easing function
1794
+ * or the type of the easing: {@values 'linear', 'easeInQuad',
1795
+ * 'easeOutQuad', 'easeInOutQuad', 'easeInCubic', 'easeOutCubic',
1796
+ * 'easeInOutCubic', 'easeInQuart', 'easeOutQuart', 'easeInOutQuart',
1797
+ * 'easeInQuint', 'easeOutQuint', 'easeInOutQuint', 'easeInSine',
1798
+ * 'easeOutSine', 'easeInOutSine', 'easeInExpo', 'easeOutExpo',
1799
+ * 'easeInOutExpo', 'easeInCirc', 'easeOutCirc', 'easeInOutCirc'}
1800
+ * @option [options.start=true] {Boolean} whether to start tweening
1801
+ * automatically
1802
+ *
1803
+ * @param from the state at the start of the tweening
1804
+ * @param to the state at the end of the tweening
1805
+ * @param options the options or the duration
1806
+ *
1807
+ * @example {@paperscript height=100}
1808
+ * // Tween fillColor:
1809
+ * var path = Path.circle({
1810
+ * radius: view.bounds.height * 0.4,
1811
+ * center: view.center
1812
+ * });
1813
+ * path.tween(
1814
+ * { fillColor: 'blue' },
1815
+ * { fillColor: 'red' },
1816
+ * 3000
1817
+ * );
1818
+ * @example {@paperscript height=100}
1819
+ * // Tween rotation:
1820
+ * var path = Shape.rectangle({
1821
+ * fillColor: 'red',
1822
+ * center: [50, view.center.y],
1823
+ * size: [60, 60]
1824
+ * });
1825
+ * path.tween({
1826
+ * rotation: 180,
1827
+ * 'position.x': view.bounds.width - 50,
1828
+ * 'fillColor.hue': '+= 90'
1829
+ * }, {
1830
+ * easing: 'easeInOutCubic',
1831
+ * duration: 2000
1832
+ * });
1833
+ */
1834
+ tween(from: object | null, to: object | null, options: TweenOptions | number): Tween;
1835
+ /**
1836
+ * Tween item to a state.
1837
+ *
1838
+ * @param to the state at the end of the tweening
1839
+ * @param options the options or the duration
1840
+ *
1841
+ * @example {@paperscript height=200}
1842
+ * // Tween a nested property with relative values
1843
+ * var path = Path.rectangle({
1844
+ * size: [100, 100],
1845
+ * position: view.center,
1846
+ * fillColor: 'red',
1847
+ * });
1848
+ *
1849
+ * var delta = { x: path.bounds.width / 2, y: 0 };
1850
+ *
1851
+ * path.tween({
1852
+ * 'segments[1].point': ['+=', delta],
1853
+ * 'segments[2].point.x': '-= 50'
1854
+ * }, 3000);
1855
+ *
1856
+ * @see Item#tween(from, to, options)
1857
+ */
1858
+ tween(to: object, options: TweenOptions | number): Tween;
1859
+ /**
1860
+ * Tween item.
1861
+ *
1862
+ * @param options the options or the duration
1863
+ *
1864
+ * @see Item#tween(from, to, options)
1865
+ *
1866
+ * @example {@paperscript height=100}
1867
+ * // Start an empty tween and just use the update callback:
1868
+ * var path = Path.circle({
1869
+ * fillColor: 'blue',
1870
+ * radius: view.bounds.height * 0.4,
1871
+ * center: view.center,
1872
+ * });
1873
+ * var pathFrom = path.clone({ insert: false })
1874
+ * var pathTo = Path.rectangle({
1875
+ * position: view.center,
1876
+ * rectangle: path.bounds,
1877
+ * insert: false
1878
+ * });
1879
+ * path.tween(2000).onUpdate = function(event) {
1880
+ * path.interpolate(pathFrom, pathTo, event.factor)
1881
+ * };
1882
+ */
1883
+ tween(options: TweenOptions | number): Tween;
1884
+ /**
1885
+ *
1886
+ * Tween item to a state.
1887
+ *
1888
+ * @param to the state at the end of the tweening
1889
+ * @param options the options or the duration
1890
+ *
1891
+ * @see Item#tween(to, options)
1892
+ */
1893
+ tweenTo(to: object, options: TweenOptions | number): Tween;
1894
+ /**
1895
+ *
1896
+ * Tween item from a state to its state before the tweening.
1897
+ *
1898
+ * @param from the state at the start of the tweening
1899
+ * @param options the options or the duration
1900
+ *
1901
+ * @see Item#tween(from, to, options)
1902
+ *
1903
+ * @example {@paperscript height=100}
1904
+ * // Tween fillColor from red to the path's initial fillColor:
1905
+ * var path = Path.circle({
1906
+ * fillColor: 'blue',
1907
+ * radius: view.bounds.height * 0.4,
1908
+ * center: view.center
1909
+ * });
1910
+ * path.tweenFrom({ fillColor: 'red' }, { duration: 1000 });
1911
+ */
1912
+ tweenFrom(from: object, options: TweenOptions | number): Tween;
1913
+ /**
1914
+ * The function to be called whenever any item of the class or of its
1915
+ * subclasses is drawn, as {@link #onDraw} is for a single item, e.g.
1916
+ * `Path.onDraw` for all paths, including the ones created later. The
1917
+ * item's own handlers are called first, then the ones of its class and of
1918
+ * the classes it inherits from, up to `Item`, with `this` set to the item.
1919
+ * `Path.on('draw', handler)` and `Path.off('draw', handler)` attach and
1920
+ * detach them too. Only the drawing events can be handled for classes of
1921
+ * items. Classes are shared by all {@link PaperScope} objects, and so are
1922
+ * their handlers.
1923
+ */
1924
+ static onDraw: Handler | null;
1925
+ /**
1926
+ * The function to be called when the selection of any selected item of the
1927
+ * class or of its subclasses is drawn, as {@link #onDrawSelection} is for
1928
+ * a single item, e.g. `Path.onDrawSelection` for all paths, see
1929
+ * {@link Item.onDraw}.
1930
+ */
1931
+ static onDrawSelection: Handler | null;
1932
+ /**
1933
+ * Specifies whether the item is locked. When set to `true`, item
1934
+ * interactions with the mouse are disabled.
1935
+ *
1936
+ * @default false
1937
+ *
1938
+ * @example {@paperscript}
1939
+ * var unlockedItem = Path.circle({
1940
+ * center: view.center - [35, 0],
1941
+ * radius: 30,
1942
+ * fillColor: 'springgreen',
1943
+ * onMouseDown: function() {
1944
+ * this.fillColor = Color.random();
1945
+ * }
1946
+ * });
1947
+ *
1948
+ * var lockedItem = Path.circle({
1949
+ * center: view.center + [35, 0],
1950
+ * radius: 30,
1951
+ * fillColor: 'crimson',
1952
+ * locked: true,
1953
+ * // This event won't be triggered because the item is locked.
1954
+ * onMouseDown: function() {
1955
+ * this.fillColor = Color.random();
1956
+ * }
1957
+ * });
1958
+ *
1959
+ * new PointText({
1960
+ * content: 'Click on both circles to see which one is locked.',
1961
+ * point: view.center - [0, 35],
1962
+ * justification: 'center'
1963
+ * });
1964
+ */
1965
+ get locked(): boolean;
1966
+ set locked(locked: boolean);
1967
+ /**
1968
+ * Specifies whether the item is visible. When set to `false`, the item
1969
+ * won't be drawn.
1970
+ *
1971
+ * @default true
1972
+ *
1973
+ * @example {@paperscript}
1974
+ * // Hiding an item:
1975
+ * var path = Path.circle({
1976
+ * center: [50, 50],
1977
+ * radius: 20,
1978
+ * fillColor: 'red'
1979
+ * });
1980
+ *
1981
+ * // Hide the path:
1982
+ * path.visible = false;
1983
+ */
1984
+ get visible(): boolean;
1985
+ set visible(visible: boolean);
1986
+ /**
1987
+ * The blend mode with which the item is composited onto the canvas. Both
1988
+ * the standard canvas compositing modes, as well as the new CSS blend modes
1989
+ * are supported. Where the canvas doesn't support a CSS blend mode
1990
+ * natively, it draws as `'normal'`. Paper.js's own modes `'add'`,
1991
+ * `'subtract'`, `'average'`, `'pin-light'` and `'negation'` are emulated,
1992
+ * which can have an impact on performance.
1993
+ *
1994
+ * @values 'normal', 'multiply', 'screen', 'overlay', 'soft-light', 'hard-
1995
+ * light', 'color-dodge', 'color-burn', 'darken', 'lighten',
1996
+ * 'difference', 'exclusion', 'hue', 'saturation', 'luminosity',
1997
+ * 'color', 'add', 'subtract', 'average', 'pin-light', 'negation',
1998
+ * 'source-over', 'source-in', 'source-out', 'source-atop',
1999
+ * 'destination-over', 'destination-in', 'destination-out',
2000
+ * 'destination-atop', 'lighter', 'darker', 'copy', 'xor'
2001
+ * @default 'normal'
2002
+ *
2003
+ * @example {@paperscript}
2004
+ * // Setting an item's blend mode:
2005
+ *
2006
+ * // Create a white rectangle in the background
2007
+ * // with the same dimensions as the view:
2008
+ * var background = Path.rectangle(view.bounds);
2009
+ * background.fillColor = 'white';
2010
+ *
2011
+ * var circle = Path.circle({
2012
+ * center: [80, 50],
2013
+ * radius: 35,
2014
+ * fillColor: 'red'
2015
+ * });
2016
+ *
2017
+ * var circle2 = Path.circle({
2018
+ * center: new Point(120, 50),
2019
+ * radius: 35,
2020
+ * fillColor: 'blue'
2021
+ * });
2022
+ *
2023
+ * // Set the blend mode of circle2:
2024
+ * circle2.blendMode = 'multiply';
2025
+ */
2026
+ get blendMode(): BlendMode;
2027
+ set blendMode(blendMode: BlendMode);
2028
+ /**
2029
+ * The opacity of the item as a value between `0` and `1`.
2030
+ *
2031
+ * @default 1
2032
+ *
2033
+ * @example {@paperscript}
2034
+ * // Making an item 50% transparent:
2035
+ * var circle = Path.circle({
2036
+ * center: [80, 50],
2037
+ * radius: 35,
2038
+ * fillColor: 'red'
2039
+ * });
2040
+ *
2041
+ * var circle2 = Path.circle({
2042
+ * center: new Point(120, 50),
2043
+ * radius: 35,
2044
+ * fillColor: 'blue',
2045
+ * strokeColor: 'green',
2046
+ * strokeWidth: 10
2047
+ * });
2048
+ *
2049
+ * // Make circle2 50% transparent:
2050
+ * circle2.opacity = 0.5;
2051
+ */
2052
+ get opacity(): number;
2053
+ set opacity(opacity: number);
2054
+ /**
2055
+ * Specifies whether the item functions as a guide. When set to `true`, the
2056
+ * item is drawn as usual, but left out of hit-tests and mouse
2057
+ * interactions. Hit-tests only find guides when `options.guides` is set,
2058
+ * and then only them, see {@link #hitTest(point[, options])}.
2059
+ *
2060
+ * @default false
2061
+ */
2062
+ get guide(): boolean;
2063
+ set guide(guide: boolean);
2064
+ /**
2065
+ * The bounding rectangle of the item including handles.
2066
+ */
2067
+ get handleBounds(): Rectangle;
2068
+ /**
2069
+ * Returns the bounding rectangle of the item including handles, transformed
2070
+ * by the matrix instead of the item's own matrix.
2071
+ *
2072
+ * @param [matrix] the matrix to transform the item's content by
2073
+ * @return the bounds
2074
+ */
2075
+ getHandleBounds(matrix?: Matrix | null): Rectangle;
2076
+ /**
2077
+ * The bounding rectangle of the item without any matrix transformations.
2078
+ *
2079
+ * Typical use case would be drawing a frame around the object where you
2080
+ * want to draw something of the same size, position, rotation, and scaling,
2081
+ * like a selection frame.
2082
+ */
2083
+ get internalBounds(): Rectangle;
2084
+ /**
2085
+ * Returns the bounding rectangle of the item's content, transformed by the
2086
+ * matrix instead of none.
2087
+ *
2088
+ * @param [matrix] the matrix to transform the item's content by
2089
+ * @return the bounds
2090
+ */
2091
+ getInternalBounds(matrix?: Matrix | null): Rectangle;
2092
+ /**
2093
+ * Rotates the item by a given angle around the given center point.
2094
+ *
2095
+ * Angles are oriented clockwise and measured in degrees.
2096
+ *
2097
+ * @param angle the rotation angle
2098
+ * @param [center={@link Item#position}]
2099
+ * @see Matrix#rotate(angle[, center])
2100
+ *
2101
+ * @example {@paperscript}
2102
+ * // Rotating an item:
2103
+ *
2104
+ * // Create a rectangle shaped path with its top left
2105
+ * // point at {x: 80, y: 25} and a size of {width: 50, height: 50}:
2106
+ * var path = Path.rectangle(new Point(80, 25), new Size(50, 50));
2107
+ * path.fillColor = 'black';
2108
+ *
2109
+ * // Rotate the path by 30 degrees:
2110
+ * path.rotate(30);
2111
+ *
2112
+ * @example {@paperscript height=200}
2113
+ * // Rotating an item around a specific point:
2114
+ *
2115
+ * // Create a rectangle shaped path with its top left
2116
+ * // point at {x: 175, y: 50} and a size of {width: 100, height: 100}:
2117
+ * var topLeft = new Point(175, 50);
2118
+ * var size = new Size(100, 100);
2119
+ * var path = Path.rectangle(topLeft, size);
2120
+ * path.fillColor = 'black';
2121
+ *
2122
+ * // Draw a circle shaped path in the center of the view,
2123
+ * // to show the rotation point:
2124
+ * var circle = Path.circle({
2125
+ * center: view.center,
2126
+ * radius: 5,
2127
+ * fillColor: 'white'
2128
+ * });
2129
+ *
2130
+ * // Each frame rotate the path 3 degrees around the center point
2131
+ * // of the view:
2132
+ * function onFrame(event) {
2133
+ * path.rotate(3, view.center);
2134
+ * }
2135
+ */
2136
+ rotate(angle: number, center?: PointLike): this;
2137
+ /**
2138
+ * Scales the item by the given value from its center point, or optionally
2139
+ * from a supplied point.
2140
+ *
2141
+ * @param scale the scale factor
2142
+ * @param [center={@link Item#position}]
2143
+ *
2144
+ * @example {@paperscript}
2145
+ * // Scaling an item from its center point:
2146
+ *
2147
+ * // Create a circle shaped path at { x: 80, y: 50 }
2148
+ * // with a radius of 20:
2149
+ * var circle = Path.circle({
2150
+ * center: [80, 50],
2151
+ * radius: 20,
2152
+ * fillColor: 'red'
2153
+ * });
2154
+ *
2155
+ * // Scale the path by 150% from its center point
2156
+ * circle.scale(1.5);
2157
+ *
2158
+ * @example {@paperscript}
2159
+ * // Scaling an item from a specific point:
2160
+ *
2161
+ * // Create a circle shaped path at { x: 80, y: 50 }
2162
+ * // with a radius of 20:
2163
+ * var circle = Path.circle({
2164
+ * center: [80, 50],
2165
+ * radius: 20,
2166
+ * fillColor: 'red'
2167
+ * });
2168
+ *
2169
+ * // Scale the path 150% from its bottom left corner
2170
+ * circle.scale(1.5, circle.bounds.bottomLeft);
2171
+ */
2172
+ scale(scale: PointLike | number, center?: PointLike): this;
2173
+ /**
2174
+ * Scales the item by the given values from its center point, or optionally
2175
+ * from a supplied point.
2176
+ *
2177
+ * @param hor the horizontal scale factor
2178
+ * @param ver the vertical scale factor
2179
+ * @param [center={@link Item#position}]
2180
+ *
2181
+ * @example {@paperscript}
2182
+ * // Scaling an item horizontally by 300%:
2183
+ *
2184
+ * // Create a circle shaped path at { x: 100, y: 50 }
2185
+ * // with a radius of 20:
2186
+ * var circle = Path.circle({
2187
+ * center: [100, 50],
2188
+ * radius: 20,
2189
+ * fillColor: 'red'
2190
+ * });
2191
+ *
2192
+ * // Scale the path horizontally by 300%
2193
+ * circle.scale(3, 1);
2194
+ */
2195
+ scale(hor: number, ver: number, center?: PointLike): this;
2196
+ /**
2197
+ * Shears the item by the given value from its center point, or optionally
2198
+ * by a supplied point.
2199
+ *
2200
+ * @param shear the horizontal and vertical shear factors as a point
2201
+ * @param [center={@link Item#position}]
2202
+ * @see Matrix#shear(shear[, center])
2203
+ */
2204
+ shear(shear: PointLike | number, center?: PointLike): this;
2205
+ /**
2206
+ * Shears the item by the given values from its center point, or optionally
2207
+ * by a supplied point.
2208
+ *
2209
+ * @param hor the horizontal shear factor
2210
+ * @param ver the vertical shear factor
2211
+ * @param [center={@link Item#position}]
2212
+ * @see Matrix#shear(hor, ver[, center])
2213
+ */
2214
+ shear(hor: number, ver: number, center?: PointLike): this;
2215
+ /**
2216
+ * Skews the item by the given angles from its center point, or optionally
2217
+ * by a supplied point.
2218
+ *
2219
+ * @param skew the horizontal and vertical skew angles in degrees
2220
+ * @param [center={@link Item#position}]
2221
+ * @see Matrix#skew(skew[, center])
2222
+ */
2223
+ skew(skew: PointLike | number, center?: PointLike): this;
2224
+ /**
2225
+ * Skews the item by the given angles from its center point, or optionally
2226
+ * by a supplied point.
2227
+ *
2228
+ * @param hor the horizontal skew angle in degrees
2229
+ * @param ver the vertical skew angle in degrees
2230
+ * @param [center={@link Item#position}]
2231
+ * @see Matrix#skew(hor, ver[, center])
2232
+ */
2233
+ skew(hor: number, ver: number, center?: PointLike): this;
2234
+ /**
2235
+ * Removes the item when the next {@link Tool#onMouseMove} event is fired.
2236
+ *
2237
+ * @example {@paperscript height=200}
2238
+ * // Move your mouse below:
2239
+ * function onMouseMove(event) {
2240
+ * // Create a circle shaped path at the mouse position,
2241
+ * // with a radius of 10:
2242
+ * var path = Path.circle({
2243
+ * center: event.point,
2244
+ * radius: 10,
2245
+ * fillColor: 'black'
2246
+ * });
2247
+ *
2248
+ * // On the next move event, automatically remove the path:
2249
+ * path.removeOnMove();
2250
+ * }
2251
+ */
2252
+ removeOnMove(): this;
2253
+ /**
2254
+ * Removes the item when the next {@link Tool#onMouseDown} event is fired.
2255
+ *
2256
+ * @example {@paperscript height=200}
2257
+ * // Click a few times below:
2258
+ * function onMouseDown(event) {
2259
+ * // Create a circle shaped path at the mouse position,
2260
+ * // with a radius of 10:
2261
+ * var path = Path.circle({
2262
+ * center: event.point,
2263
+ * radius: 10,
2264
+ * fillColor: 'black'
2265
+ * });
2266
+ *
2267
+ * // Remove the path, next time the mouse is pressed:
2268
+ * path.removeOnDown();
2269
+ * }
2270
+ */
2271
+ removeOnDown(): this;
2272
+ /**
2273
+ * Removes the item when the next {@link Tool#onMouseDrag} event is fired.
2274
+ *
2275
+ * @example {@paperscript height=200}
2276
+ * // Click and drag below:
2277
+ * function onMouseDrag(event) {
2278
+ * // Create a circle shaped path at the mouse position,
2279
+ * // with a radius of 10:
2280
+ * var path = Path.circle({
2281
+ * center: event.point,
2282
+ * radius: 10,
2283
+ * fillColor: 'black'
2284
+ * });
2285
+ *
2286
+ * // On the next drag event, automatically remove the path:
2287
+ * path.removeOnDrag();
2288
+ * }
2289
+ */
2290
+ removeOnDrag(): this;
2291
+ /**
2292
+ * Removes the item when the next {@link Tool#onMouseUp} event is fired.
2293
+ *
2294
+ * @example {@paperscript height=200}
2295
+ * // Click a few times below:
2296
+ * function onMouseDown(event) {
2297
+ * // Create a circle shaped path at the mouse position,
2298
+ * // with a radius of 10:
2299
+ * var path = Path.circle({
2300
+ * center: event.point,
2301
+ * radius: 10,
2302
+ * fillColor: 'black'
2303
+ * });
2304
+ *
2305
+ * // Remove the path, when the mouse is released:
2306
+ * path.removeOnUp();
2307
+ * }
2308
+ */
2309
+ removeOnUp(): this;
2310
+ _setAttribute<K extends '_locked' | '_visible' | '_blendMode' | '_opacity' | '_guide'>(key: K, value: this[K], flags: number): void;
2311
+ }
2312
+ export interface Item extends ItemStyleProperties {
2313
+ /**
2314
+ * {@grouptitle Event Handlers}
2315
+ *
2316
+ * Item level handler function to be called on each frame of an animation.
2317
+ * The function receives an event object which contains information about
2318
+ * the frame event:
2319
+ *
2320
+ * @option event.count {Number} the number of times the frame event was
2321
+ * fired
2322
+ * @option event.time {Number} the total amount of time passed since the
2323
+ * first frame event in seconds
2324
+ * @option event.delta {Number} the time passed in seconds since the last
2325
+ * frame event
2326
+ *
2327
+ * @see View#onFrame
2328
+ *
2329
+ * @example {@paperscript}
2330
+ * // Creating an animation:
2331
+ *
2332
+ * // Create a rectangle shaped path with its top left point at:
2333
+ * // {x: 50, y: 25} and a size of {width: 50, height: 50}
2334
+ * var path = Path.rectangle(new Point(50, 25), new Size(50, 50));
2335
+ * path.fillColor = 'black';
2336
+ *
2337
+ * path.onFrame = function(event) {
2338
+ * // Every frame, rotate the path by 3 degrees:
2339
+ * this.rotate(3);
2340
+ * }
2341
+ */
2342
+ get onFrame(): Handler<this, FrameEvent> | null;
2343
+ set onFrame(func: Handler<this, FrameEvent> | null);
2344
+ /**
2345
+ * The function to be called when the mouse button is pushed down on the
2346
+ * item. The function receives a {@link MouseEvent} object which contains
2347
+ * information about the mouse event.
2348
+ * Note that such mouse events bubble up the scene graph hierarchy and will
2349
+ * reach the view, unless they are stopped with {@link
2350
+ * Event#stopPropagation()} or by returning `false` from the handler.
2351
+ *
2352
+ * @see View#onMouseDown
2353
+ *
2354
+ * @example {@paperscript}
2355
+ * // Press the mouse button down on the circle shaped path, to make it red:
2356
+ *
2357
+ * // Create a circle shaped path at the center of the view:
2358
+ * var path = Path.circle({
2359
+ * center: view.center,
2360
+ * radius: 25,
2361
+ * fillColor: 'black'
2362
+ * });
2363
+ *
2364
+ * // When the mouse is pressed on the item,
2365
+ * // set its fill color to red:
2366
+ * path.onMouseDown = function(event) {
2367
+ * this.fillColor = 'red';
2368
+ * }
2369
+ *
2370
+ * @example {@paperscript}
2371
+ * // Press the mouse on the circle shaped paths to remove them:
2372
+ *
2373
+ * // Loop 30 times:
2374
+ * for (var i = 0; i < 30; i++) {
2375
+ * // Create a circle shaped path at a random position
2376
+ * // in the view:
2377
+ * var path = Path.circle({
2378
+ * center: Point.random() * view.size,
2379
+ * radius: 25,
2380
+ * fillColor: 'black',
2381
+ * strokeColor: 'white'
2382
+ * });
2383
+ *
2384
+ * // When the mouse is pressed on the item, remove it:
2385
+ * path.onMouseDown = function(event) {
2386
+ * this.remove();
2387
+ * }
2388
+ * }
2389
+ */
2390
+ get onMouseDown(): Handler<this, MouseEvent> | null;
2391
+ set onMouseDown(func: Handler<this, MouseEvent> | null);
2392
+ /**
2393
+ * The function to be called when the mouse position changes while the mouse
2394
+ * is being dragged over the item. The function receives a {@link
2395
+ * MouseEvent} object which contains information about the mouse event.
2396
+ * Note that such mouse events bubble up the scene graph hierarchy and will
2397
+ * reach the view, unless they are stopped with {@link
2398
+ * Event#stopPropagation()} or by returning `false` from the handler.
2399
+ *
2400
+ * @see View#onMouseDrag
2401
+ *
2402
+ * @example {@paperscript height=240}
2403
+ * // Press and drag the mouse on the blue circle to move it:
2404
+ *
2405
+ * // Create a circle shaped path at the center of the view:
2406
+ * var path = Path.circle({
2407
+ * center: view.center,
2408
+ * radius: 50,
2409
+ * fillColor: 'blue'
2410
+ * });
2411
+ *
2412
+ * // Install a drag event handler that moves the path along.
2413
+ * path.onMouseDrag = function(event) {
2414
+ * path.position += event.delta;
2415
+ * }
2416
+ */
2417
+ get onMouseDrag(): Handler<this, MouseEvent> | null;
2418
+ set onMouseDrag(func: Handler<this, MouseEvent> | null);
2419
+ /**
2420
+ * The function to be called when the mouse button is released over the item.
2421
+ * The function receives a {@link MouseEvent} object which contains
2422
+ * information about the mouse event.
2423
+ * Note that such mouse events bubble up the scene graph hierarchy and will
2424
+ * reach the view, unless they are stopped with {@link
2425
+ * Event#stopPropagation()} or by returning `false` from the handler.
2426
+ *
2427
+ * @see View#onMouseUp
2428
+ *
2429
+ * @example {@paperscript}
2430
+ * // Release the mouse button over the circle shaped path, to make it red:
2431
+ *
2432
+ * // Create a circle shaped path at the center of the view:
2433
+ * var path = Path.circle({
2434
+ * center: view.center,
2435
+ * radius: 25,
2436
+ * fillColor: 'black'
2437
+ * });
2438
+ *
2439
+ * // When the mouse is released over the item,
2440
+ * // set its fill color to red:
2441
+ * path.onMouseUp = function(event) {
2442
+ * this.fillColor = 'red';
2443
+ * }
2444
+ */
2445
+ get onMouseUp(): Handler<this, MouseEvent> | null;
2446
+ set onMouseUp(func: Handler<this, MouseEvent> | null);
2447
+ /**
2448
+ * The function to be called when the mouse clicks on the item. The function
2449
+ * receives a {@link MouseEvent} object which contains information about the
2450
+ * mouse event.
2451
+ * Note that such mouse events bubble up the scene graph hierarchy and will
2452
+ * reach the view, unless they are stopped with {@link
2453
+ * Event#stopPropagation()} or by returning `false` from the handler.
2454
+ *
2455
+ * @see View#onClick
2456
+ *
2457
+ * @example {@paperscript}
2458
+ * // Click on the circle shaped path, to make it red:
2459
+ *
2460
+ * // Create a circle shaped path at the center of the view:
2461
+ * var path = Path.circle({
2462
+ * center: view.center,
2463
+ * radius: 25,
2464
+ * fillColor: 'black'
2465
+ * });
2466
+ *
2467
+ * // When the mouse is clicked on the item,
2468
+ * // set its fill color to red:
2469
+ * path.onClick = function(event) {
2470
+ * this.fillColor = 'red';
2471
+ * }
2472
+ *
2473
+ * @example {@paperscript}
2474
+ * // Click on the circle shaped paths to remove them:
2475
+ *
2476
+ * // Loop 30 times:
2477
+ * for (var i = 0; i < 30; i++) {
2478
+ * // Create a circle shaped path at a random position
2479
+ * // in the view:
2480
+ * var path = Path.circle({
2481
+ * center: Point.random() * view.size,
2482
+ * radius: 25,
2483
+ * fillColor: 'black',
2484
+ * strokeColor: 'white'
2485
+ * });
2486
+ *
2487
+ * // When the mouse clicks on the item, remove it:
2488
+ * path.onClick = function(event) {
2489
+ * this.remove();
2490
+ * }
2491
+ * }
2492
+ */
2493
+ get onClick(): Handler<this, MouseEvent> | null;
2494
+ set onClick(func: Handler<this, MouseEvent> | null);
2495
+ /**
2496
+ * The function to be called when the mouse double clicks on the item. The
2497
+ * function receives a {@link MouseEvent} object which contains information
2498
+ * about the mouse event.
2499
+ * Note that such mouse events bubble up the scene graph hierarchy and will
2500
+ * reach the view, unless they are stopped with {@link
2501
+ * Event#stopPropagation()} or by returning `false` from the handler.
2502
+ *
2503
+ * @see View#onDoubleClick
2504
+ *
2505
+ * @example {@paperscript}
2506
+ * // Double click on the circle shaped path, to make it red:
2507
+ *
2508
+ * // Create a circle shaped path at the center of the view:
2509
+ * var path = Path.circle({
2510
+ * center: view.center,
2511
+ * radius: 25,
2512
+ * fillColor: 'black'
2513
+ * });
2514
+ *
2515
+ * // When the mouse is double clicked on the item,
2516
+ * // set its fill color to red:
2517
+ * path.onDoubleClick = function(event) {
2518
+ * this.fillColor = 'red';
2519
+ * }
2520
+ *
2521
+ * @example {@paperscript}
2522
+ * // Double click on the circle shaped paths to remove them:
2523
+ *
2524
+ * // Loop 30 times:
2525
+ * for (var i = 0; i < 30; i++) {
2526
+ * // Create a circle shaped path at a random position
2527
+ * // in the view:
2528
+ * var path = Path.circle({
2529
+ * center: Point.random() * view.size,
2530
+ * radius: 25,
2531
+ * fillColor: 'black',
2532
+ * strokeColor: 'white'
2533
+ * });
2534
+ *
2535
+ * // When the mouse is double clicked on the item, remove it:
2536
+ * path.onDoubleClick = function(event) {
2537
+ * this.remove();
2538
+ * }
2539
+ * }
2540
+ */
2541
+ get onDoubleClick(): Handler<this, MouseEvent> | null;
2542
+ set onDoubleClick(func: Handler<this, MouseEvent> | null);
2543
+ /**
2544
+ * The function to be called repeatedly while the mouse moves over the item.
2545
+ * The function receives a {@link MouseEvent} object which contains
2546
+ * information about the mouse event.
2547
+ * Note that such mouse events bubble up the scene graph hierarchy and will
2548
+ * reach the view, unless they are stopped with {@link
2549
+ * Event#stopPropagation()} or by returning `false` from the handler.
2550
+ *
2551
+ * @see View#onMouseMove
2552
+ *
2553
+ * @example {@paperscript}
2554
+ * // Move over the circle shaped path, to change its opacity:
2555
+ *
2556
+ * // Create a circle shaped path at the center of the view:
2557
+ * var path = Path.circle({
2558
+ * center: view.center,
2559
+ * radius: 25,
2560
+ * fillColor: 'black'
2561
+ * });
2562
+ *
2563
+ * // When the mouse moves on top of the item, set its opacity
2564
+ * // to a random value between 0 and 1:
2565
+ * path.onMouseMove = function(event) {
2566
+ * this.opacity = Math.random();
2567
+ * }
2568
+ */
2569
+ get onMouseMove(): Handler<this, MouseEvent> | null;
2570
+ set onMouseMove(func: Handler<this, MouseEvent> | null);
2571
+ /**
2572
+ * The function to be called when the mouse moves over the item. This
2573
+ * function will only be called again, once the mouse moved outside of the
2574
+ * item first. The function receives a {@link MouseEvent} object which
2575
+ * contains information about the mouse event.
2576
+ * Note that such mouse events bubble up the scene graph hierarchy and will
2577
+ * reach the view, unless they are stopped with {@link
2578
+ * Event#stopPropagation()} or by returning `false` from the handler.
2579
+ *
2580
+ * @see View#onMouseEnter
2581
+ *
2582
+ * @example {@paperscript}
2583
+ * // When you move the mouse over the item, its fill color is set to red.
2584
+ * // When you move the mouse outside again, its fill color is set back
2585
+ * // to black.
2586
+ *
2587
+ * // Create a circle shaped path at the center of the view:
2588
+ * var path = Path.circle({
2589
+ * center: view.center,
2590
+ * radius: 25,
2591
+ * fillColor: 'black'
2592
+ * });
2593
+ *
2594
+ * // When the mouse enters the item, set its fill color to red:
2595
+ * path.onMouseEnter = function(event) {
2596
+ * this.fillColor = 'red';
2597
+ * }
2598
+ *
2599
+ * // When the mouse leaves the item, set its fill color to black:
2600
+ * path.onMouseLeave = function(event) {
2601
+ * this.fillColor = 'black';
2602
+ * }
2603
+ * @example {@paperscript}
2604
+ * // When you click the mouse, you create new circle shaped items. When you
2605
+ * // move the mouse over the item, its fill color is set to red. When you
2606
+ * // move the mouse outside again, its fill color is set back
2607
+ * // to black.
2608
+ *
2609
+ * function enter(event) {
2610
+ * this.fillColor = 'red';
2611
+ * }
2612
+ *
2613
+ * function leave(event) {
2614
+ * this.fillColor = 'black';
2615
+ * }
2616
+ *
2617
+ * // When the mouse is pressed:
2618
+ * function onMouseDown(event) {
2619
+ * // Create a circle shaped path at the position of the mouse:
2620
+ * var path = Path.circle(event.point, 25);
2621
+ * path.fillColor = 'black';
2622
+ *
2623
+ * // When the mouse enters the item, set its fill color to red:
2624
+ * path.onMouseEnter = enter;
2625
+ *
2626
+ * // When the mouse leaves the item, set its fill color to black:
2627
+ * path.onMouseLeave = leave;
2628
+ * }
2629
+ */
2630
+ get onMouseEnter(): Handler<this, MouseEvent> | null;
2631
+ set onMouseEnter(func: Handler<this, MouseEvent> | null);
2632
+ /**
2633
+ * The function to be called when the mouse moves out of the item.
2634
+ * The function receives a {@link MouseEvent} object which contains
2635
+ * information about the mouse event.
2636
+ * Note that such mouse events bubble up the scene graph hierarchy and will
2637
+ * reach the view, unless they are stopped with {@link
2638
+ * Event#stopPropagation()} or by returning `false` from the handler.
2639
+ *
2640
+ * @see View#onMouseLeave
2641
+ *
2642
+ * @example {@paperscript}
2643
+ * // Move the mouse over the circle shaped path and then move it out
2644
+ * // of it again to set its fill color to red:
2645
+ *
2646
+ * // Create a circle shaped path at the center of the view:
2647
+ * var path = Path.circle({
2648
+ * center: view.center,
2649
+ * radius: 25,
2650
+ * fillColor: 'black'
2651
+ * });
2652
+ *
2653
+ * // When the mouse leaves the item, set its fill color to red:
2654
+ * path.onMouseLeave = function(event) {
2655
+ * this.fillColor = 'red';
2656
+ * }
2657
+ */
2658
+ get onMouseLeave(): Handler<this, MouseEvent> | null;
2659
+ set onMouseLeave(func: Handler<this, MouseEvent> | null);
2660
+ /**
2661
+ * The function to be called whenever the item is drawn: in views, in
2662
+ * {@link #rasterize()}, and once for each placement of a symbol whose
2663
+ * definition contains it. It is called right before the item's default
2664
+ * drawing, and draws with the canvas API beneath it, or replaces it by
2665
+ * returning `false` or calling `event.preventDefault()`.
2666
+ *
2667
+ * What the handler draws isn't part of the item's hit testing, its bounds
2668
+ * or its SVG export. In buffered groups, it is only called when the group
2669
+ * draws its buffer again, see {@link Group#buffered}.
2670
+ *
2671
+ * The function receives a {@link DrawEvent} object with these fields:
2672
+ *
2673
+ * @option event.item {Item} the item that is drawn
2674
+ * @option event.context {CanvasRenderingContext2D} the canvas context,
2675
+ * transformed into the item's coordinates
2676
+ * @option event.matrix {Matrix} the matrix from the item's coordinates to
2677
+ * the pixels of the view, without its pixel ratio, for drawing things
2678
+ * at a size in pixels
2679
+ * @option event.pixelRatio {Number} the device pixels per pixel: the
2680
+ * view's pixel ratio, or the resolution divided by 72 in
2681
+ * {@link #rasterize()}
2682
+ * @option event.view {View} the view drawn into, or `null` in
2683
+ * {@link #rasterize()}
2684
+ *
2685
+ * @example {@paperscript}
2686
+ * // Draw a hairline cross through the center of a circle, beneath it:
2687
+ * var path = Path.circle({
2688
+ * center: view.center,
2689
+ * radius: 25,
2690
+ * fillColor: 'rgba(255, 0, 0, 0.5)'
2691
+ * });
2692
+ *
2693
+ * path.onDraw = function(event) {
2694
+ * var ctx = event.context,
2695
+ * center = this.position,
2696
+ * scale = event.matrix.scaling.x;
2697
+ * ctx.beginPath();
2698
+ * ctx.moveTo(center.x - 40, center.y);
2699
+ * ctx.lineTo(center.x + 40, center.y);
2700
+ * ctx.moveTo(center.x, center.y - 40);
2701
+ * ctx.lineTo(center.x, center.y + 40);
2702
+ * ctx.lineWidth = 1 / scale;
2703
+ * ctx.stroke();
2704
+ * }
2705
+ */
2706
+ get onDraw(): Handler<this, DrawEvent> | null;
2707
+ set onDraw(func: Handler<this, DrawEvent> | null);
2708
+ /**
2709
+ * The function to be called when the selection of the selected item is
2710
+ * drawn, over all the content. It is called right before the item's
2711
+ * default selection drawing, and draws with the canvas API beneath it, or
2712
+ * replaces it by returning `false` or calling `event.preventDefault()`.
2713
+ *
2714
+ * What the handler draws isn't part of the item's hit testing, its bounds
2715
+ * or its SVG export.
2716
+ *
2717
+ * The function receives a {@link DrawEvent} object with these fields:
2718
+ *
2719
+ * @option event.item {Item} the selected item
2720
+ * @option event.context {CanvasRenderingContext2D} the canvas context, in
2721
+ * the pixels of the view, with the selection color as its `strokeStyle`
2722
+ * and `fillStyle`, and a `lineWidth` of 1
2723
+ * @option event.matrix {Matrix} the matrix from the item's coordinates to
2724
+ * the pixels of the view
2725
+ * @option event.size {Number} the size of the handles, see
2726
+ * {@link PaperScope#settings}
2727
+ * @option event.color {Color} the selection color, see
2728
+ * {@link #selectedColor}
2729
+ * @option event.view {View} the view drawn into
2730
+ *
2731
+ * @example {@paperscript}
2732
+ * // Draw the selection of a path as a dot at each segment:
2733
+ * var path = Path.star({
2734
+ * center: view.center,
2735
+ * points: 5,
2736
+ * radius1: 20,
2737
+ * radius2: 40,
2738
+ * strokeColor: 'black',
2739
+ * selected: true
2740
+ * });
2741
+ *
2742
+ * path.onDrawSelection = function(event) {
2743
+ * var ctx = event.context;
2744
+ * this.segments.forEach(function(segment) {
2745
+ * var point = event.matrix.transform(segment.point);
2746
+ * ctx.beginPath();
2747
+ * ctx.arc(point.x, point.y, event.size, 0, Math.PI * 2);
2748
+ * ctx.fill();
2749
+ * });
2750
+ * return false;
2751
+ * }
2752
+ */
2753
+ get onDrawSelection(): Handler<this, DrawEvent> | null;
2754
+ set onDrawSelection(func: Handler<this, DrawEvent> | null);
2755
+ get onLoad(): Handler<this> | null;
2756
+ set onLoad(func: Handler<this> | null);
2757
+ get onError(): Handler<this> | null;
2758
+ set onError(func: Handler<this> | null);
2759
+ /**
2760
+ * {@grouptitle Event Handling}
2761
+ *
2762
+ * Attaches an event handler to the item.
2763
+ *
2764
+ * @param type the type of event: {@values 'frame', 'mousedown',
2765
+ * 'mouseup', 'mousedrag', 'click', 'doubleclick', 'mousemove',
2766
+ * 'mouseenter', 'mouseleave', 'draw', 'drawselection'}
2767
+ * @param func the function to be called when the event
2768
+ * occurs, receiving a {@link MouseEvent} or {@link Event} object as its
2769
+ * sole argument
2770
+ * @return this item itself, so calls can be chained
2771
+ * @chainable
2772
+ *
2773
+ * @example {@paperscript}
2774
+ * // Change the fill color of the path to red when the mouse enters its
2775
+ * // shape and back to black again, when it leaves its shape.
2776
+ *
2777
+ * // Create a circle shaped path at the center of the view:
2778
+ * var path = Path.circle({
2779
+ * center: view.center,
2780
+ * radius: 25,
2781
+ * fillColor: 'black'
2782
+ * });
2783
+ *
2784
+ * // When the mouse enters the item, set its fill color to red:
2785
+ * path.on('mouseenter', function() {
2786
+ * this.fillColor = 'red';
2787
+ * });
2788
+ *
2789
+ * // When the mouse leaves the item, set its fill color to black:
2790
+ * path.on('mouseleave', function() {
2791
+ * this.fillColor = 'black';
2792
+ * });
2793
+ */
2794
+ on<K extends EventType<this>>(type: K, func: EventHandler<this, K>): this;
2795
+ on(type: string, func: Handler): this;
2796
+ /**
2797
+ * Attaches one or more event handlers to the item.
2798
+ *
2799
+ * @param object an object containing one or more of the following
2800
+ * properties: {@values frame, mousedown, mouseup, mousedrag, click,
2801
+ * doubleclick, mousemove, mouseenter, mouseleave, draw, drawselection}
2802
+ * @return this item itself, so calls can be chained
2803
+ * @chainable
2804
+ *
2805
+ * @example {@paperscript}
2806
+ * // Change the fill color of the path to red when the mouse enters its
2807
+ * // shape and back to black again, when it leaves its shape.
2808
+ *
2809
+ * // Create a circle shaped path at the center of the view:
2810
+ * var path = Path.circle({
2811
+ * center: view.center,
2812
+ * radius: 25
2813
+ * });
2814
+ * path.fillColor = 'black';
2815
+ *
2816
+ * // When the mouse enters the item, set its fill color to red:
2817
+ * path.on({
2818
+ * mouseenter: function(event) {
2819
+ * this.fillColor = 'red';
2820
+ * },
2821
+ * mouseleave: function(event) {
2822
+ * this.fillColor = 'black';
2823
+ * }
2824
+ * });
2825
+ * @example {@paperscript}
2826
+ * // When you click the mouse, you create new circle shaped items. When you
2827
+ * // move the mouse over the item, its fill color is set to red. When you
2828
+ * // move the mouse outside again, its fill color is set black.
2829
+ *
2830
+ * var pathHandlers = {
2831
+ * mouseenter: function(event) {
2832
+ * this.fillColor = 'red';
2833
+ * },
2834
+ * mouseleave: function(event) {
2835
+ * this.fillColor = 'black';
2836
+ * }
2837
+ * }
2838
+ *
2839
+ * // When the mouse is pressed:
2840
+ * function onMouseDown(event) {
2841
+ * // Create a circle shaped path at the position of the mouse:
2842
+ * var path = Path.circle({
2843
+ * center: event.point,
2844
+ * radius: 25,
2845
+ * fillColor: 'black'
2846
+ * });
2847
+ *
2848
+ * // Attach the handlers inside the object literal to the path:
2849
+ * path.on(pathHandlers);
2850
+ * }
2851
+ */
2852
+ on(object: EventHandlers<this, Handler>): this;
2853
+ once<K extends EventType<this>>(type: K, func: EventHandler<this, K>): this;
2854
+ once(type: string, func: Handler): this;
2855
+ /**
2856
+ * Detach an event handler from the item.
2857
+ *
2858
+ * @param type the type of event: {@values 'frame', 'mousedown',
2859
+ * 'mouseup', 'mousedrag', 'click', 'doubleclick', 'mousemove',
2860
+ * 'mouseenter', 'mouseleave', 'draw', 'drawselection'}
2861
+ * @param func the function to be detached
2862
+ * @return this item itself, so calls can be chained
2863
+ * @chainable
2864
+ */
2865
+ off(type: string, func?: Handler): this;
2866
+ /**
2867
+ * Detach one or more event handlers from the item.
2868
+ *
2869
+ * @param object an object containing one or more of the following
2870
+ * properties: {@values frame, mousedown, mouseup, mousedrag, click,
2871
+ * doubleclick, mousemove, mouseenter, mouseleave, draw, drawselection}
2872
+ * @return this item itself, so calls can be chained
2873
+ * @chainable
2874
+ */
2875
+ off(object: EventHandlers<this, Handler>): this;
2876
+ /**
2877
+ * Emit an event on the item.
2878
+ *
2879
+ * @param type the type of event: {@values 'frame', 'mousedown',
2880
+ * 'mouseup', 'mousedrag', 'click', 'doubleclick', 'mousemove',
2881
+ * 'mouseenter', 'mouseleave', 'draw', 'drawselection'}
2882
+ * @param event an object literal containing properties describing
2883
+ * the event
2884
+ * @return {@true if the event had listeners}
2885
+ */
2886
+ emit(type: string, event?: unknown, ...args: unknown[]): boolean;
2887
+ /**
2888
+ * Check if the item has one or more event handlers of the specified type.
2889
+ *
2890
+ * @param type the type of event: {@values 'frame', 'mousedown',
2891
+ * 'mouseup', 'mousedrag', 'click', 'doubleclick', 'mousemove',
2892
+ * 'mouseenter', 'mouseleave', 'draw', 'drawselection'}
2893
+ * @return {@true if the item has one or more event handlers of
2894
+ * the specified type}
2895
+ */
2896
+ responds(type: string): boolean;
2897
+ /**
2898
+ * {@grouptitle Importing / Exporting JSON and SVG}
2899
+ *
2900
+ * Exports (serializes) the item with its content and child items to a JSON
2901
+ * data string.
2902
+ *
2903
+ * @option [options.asString=true] {Boolean} whether the JSON is returned as
2904
+ * an `Object` or a `String`
2905
+ * @option [options.precision=5] {Number} the amount of fractional digits in
2906
+ * numbers used in JSON data
2907
+ *
2908
+ * @param [options] the serialization options
2909
+ * @return the exported JSON data
2910
+ */
2911
+ exportJSON(options?: {
2912
+ asString?: boolean;
2913
+ precision?: number;
2914
+ }): string | unknown[];
2915
+ _draw(ctx: CanvasRenderingContext2D, param: DrawParam, viewMatrix: Matrix, strokeMatrix?: Matrix | null): void;
2916
+ _drawGeometry?(ctx: CanvasRenderingContext2D, matrix: Matrix | null): void;
2917
+ _drawSelected?(ctx: CanvasRenderingContext2D, matrix: Matrix, selectionItems: Record<string, Item>): void;
2918
+ }
2919
+ /**
2920
+ * Imports (deserializes) JSON data, into the target if it is of the class
2921
+ * of the data's root, see Item#importJSON() and Project#importJSON().
2922
+ * References of the form `['@key']` go to resolve(key).
2923
+ *
2924
+ * @private
2925
+ */
2926
+ export declare function importJSON(json: string | any[], target?: Item | null, resolve?: ((key: string) => any) | null): any;
2927
+ export {};