paper 0.16.0 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (464) hide show
  1. package/CHANGELOG.md +294 -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 +33083 -22681
  139. package/dist/paper-full.min.js +36 -31
  140. package/dist/paper-hosted.js +33898 -23223
  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 +90 -58
  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 -23759
  283. package/dist/docs/classes/AreaText.html +0 -8708
  284. package/dist/docs/classes/ChangeFlag.html +0 -385
  285. package/dist/docs/classes/Color.html +0 -2205
  286. package/dist/docs/classes/CompoundPath.html +0 -9168
  287. package/dist/docs/classes/Curve.html +0 -2326
  288. package/dist/docs/classes/CurveLocation.html +0 -673
  289. package/dist/docs/classes/Event.html +0 -177
  290. package/dist/docs/classes/Gradient.html +0 -241
  291. package/dist/docs/classes/GradientStop.html +0 -274
  292. package/dist/docs/classes/Group.html +0 -7139
  293. package/dist/docs/classes/HitResult.html +0 -241
  294. package/dist/docs/classes/HostItem.html +0 -6836
  295. package/dist/docs/classes/Item.html +0 -6892
  296. package/dist/docs/classes/Key.html +0 -140
  297. package/dist/docs/classes/KeyEvent.html +0 -309
  298. package/dist/docs/classes/Layer.html +0 -7122
  299. package/dist/docs/classes/Matrix.html +0 -1745
  300. package/dist/docs/classes/MouseEvent.html +0 -356
  301. package/dist/docs/classes/PaperScope.html +0 -548
  302. package/dist/docs/classes/PaperScript.html +0 -202
  303. package/dist/docs/classes/Path.html +0 -12064
  304. package/dist/docs/classes/PathItem.html +0 -8930
  305. package/dist/docs/classes/PathText.html +0 -8578
  306. package/dist/docs/classes/Point.html +0 -2860
  307. package/dist/docs/classes/PointText.html +0 -8489
  308. package/dist/docs/classes/Project.html +0 -1604
  309. package/dist/docs/classes/Raster.html +0 -8069
  310. package/dist/docs/classes/Rectangle.html +0 -1698
  311. package/dist/docs/classes/Segment.html +0 -1017
  312. package/dist/docs/classes/Shape.html +0 -7570
  313. package/dist/docs/classes/Size.html +0 -1915
  314. package/dist/docs/classes/Style.html +0 -1765
  315. package/dist/docs/classes/SymbolDefinition.html +0 -312
  316. package/dist/docs/classes/SymbolItem.html +0 -6999
  317. package/dist/docs/classes/TextItem.html +0 -8332
  318. package/dist/docs/classes/TextRange.html +0 -186
  319. package/dist/docs/classes/TextStory.html +0 -355
  320. package/dist/docs/classes/Tool.html +0 -888
  321. package/dist/docs/classes/ToolEvent.html +0 -525
  322. package/dist/docs/classes/Tween.html +0 -390
  323. package/dist/docs/classes/View.html +0 -2108
  324. package/dist/docs/classes/global.html +0 -426
  325. package/dist/docs/classes/index.html +0 -88
  326. package/dist/docs/index.html +0 -11
  327. package/dist/node/canvas.js +0 -68
  328. package/dist/node/extend.js +0 -156
  329. package/dist/node/self.js +0 -67
  330. package/dist/paper-core.d.ts +0 -1
  331. package/dist/paper-core.js +0 -21834
  332. package/dist/paper-core.min.js +0 -32
  333. package/dist/paper.d.ts +0 -9630
  334. package/examples/Animated/AnimatedStar.html +0 -53
  335. package/examples/Animated/BooleanOperations.html +0 -115
  336. package/examples/Animated/CandyCrash.html +0 -151
  337. package/examples/Animated/Extruded.html +0 -50
  338. package/examples/Animated/Lines.html +0 -53
  339. package/examples/Animated/Smoothing.html +0 -70
  340. package/examples/Animated/Space.html +0 -86
  341. package/examples/Animated/SpaceUsingShapes.html +0 -79
  342. package/examples/Games/Paperoids.html +0 -569
  343. package/examples/JSON/Circle Testing.html +0 -34
  344. package/examples/JSON/Compound Path.html +0 -25
  345. package/examples/JSON/Empty Path Testing.html +0 -31
  346. package/examples/JSON/Gradients.html +0 -34
  347. package/examples/JSON/Group Transform.html +0 -28
  348. package/examples/JSON/Line Testing.html +0 -44
  349. package/examples/JSON/Random Path Testing.html +0 -42
  350. package/examples/JSON/Raster.html +0 -29
  351. package/examples/JSON/Rect and Attribute Testing.html +0 -56
  352. package/examples/JSON/Rotated Primitives.html +0 -55
  353. package/examples/JSON/Selection.html +0 -43
  354. package/examples/JSON/Shapes.html +0 -54
  355. package/examples/JSON/Symbols.html +0 -30
  356. package/examples/JSON/Text Testing.html +0 -38
  357. package/examples/JSON/Tiger.html +0 -19
  358. package/examples/JSON/Transform Test 1.html +0 -32
  359. package/examples/JSON/Transform Test 2.html +0 -30
  360. package/examples/Node.js/AnimatedStar.js +0 -52
  361. package/examples/Node.js/BooleanOperations.js +0 -36
  362. package/examples/Node.js/JSONtoPDF.js +0 -20
  363. package/examples/Node.js/Raster.js +0 -32
  364. package/examples/Node.js/RasterRemote.js +0 -33
  365. package/examples/Node.js/SvgExport.js +0 -52
  366. package/examples/Node.js/SvgImport.js +0 -23
  367. package/examples/Node.js/Tadpoles.js +0 -16
  368. package/examples/Node.js/Tadpoles.pjs +0 -278
  369. package/examples/Node.js/in.json +0 -1
  370. package/examples/Node.js/in.svg +0 -16
  371. package/examples/Paperjs.org/BooleanOperattions.html +0 -115
  372. package/examples/Paperjs.org/BouncingBalls.html +0 -103
  373. package/examples/Paperjs.org/Chain.html +0 -54
  374. package/examples/Paperjs.org/DivisionRaster.html +0 -72
  375. package/examples/Paperjs.org/FutureSplash.html +0 -122
  376. package/examples/Paperjs.org/HitTesting.html +0 -103
  377. package/examples/Paperjs.org/InteractiveTiger.html +0 -777
  378. package/examples/Paperjs.org/MetaBalls.html +0 -132
  379. package/examples/Paperjs.org/NyanRainbow.html +0 -202
  380. package/examples/Paperjs.org/PathIntersections.html +0 -76
  381. package/examples/Paperjs.org/Qbertify.html +0 -146
  382. package/examples/Paperjs.org/RadialRainbows.html +0 -80
  383. package/examples/Paperjs.org/RoundedRectangles.html +0 -41
  384. package/examples/Paperjs.org/SatieLikedToDraw.html +0 -140
  385. package/examples/Paperjs.org/Simplify.html +0 -63
  386. package/examples/Paperjs.org/SpiralRaster.html +0 -120
  387. package/examples/Paperjs.org/Tadpoles.html +0 -283
  388. package/examples/Paperjs.org/Voronoi.html +0 -134
  389. package/examples/Rasters/PhyllotaxisRaster.html +0 -96
  390. package/examples/Rasters/Raster.html +0 -34
  391. package/examples/Rasters/RotationRaster.html +0 -44
  392. package/examples/Rasters/Smoothing.html +0 -36
  393. package/examples/SVG Export/Circle Testing.html +0 -32
  394. package/examples/SVG Export/Clipping.html +0 -17
  395. package/examples/SVG Export/Compound Path.html +0 -22
  396. package/examples/SVG Export/Empty Path Testing.html +0 -28
  397. package/examples/SVG Export/Gradients.html +0 -52
  398. package/examples/SVG Export/Group Transform.html +0 -25
  399. package/examples/SVG Export/Line Testing.html +0 -41
  400. package/examples/SVG Export/Random Path Testing.html +0 -39
  401. package/examples/SVG Export/Raster.html +0 -21
  402. package/examples/SVG Export/Rect and Attribute Testing.html +0 -53
  403. package/examples/SVG Export/Rotated Primitives.html +0 -80
  404. package/examples/SVG Export/Shapes.html +0 -58
  405. package/examples/SVG Export/Symbols.html +0 -27
  406. package/examples/SVG Export/Text Testing.html +0 -45
  407. package/examples/SVG Export/Tiger.html +0 -23
  408. package/examples/SVG Export/Transform Test 1.html +0 -29
  409. package/examples/SVG Export/Transform Test 2.html +0 -27
  410. package/examples/SVG Import/Arcs.html +0 -78
  411. package/examples/SVG Import/Butterfly.html +0 -223
  412. package/examples/SVG Import/Circle and Ellipse Testing.html +0 -26
  413. package/examples/SVG Import/Clipping.html +0 -100
  414. package/examples/SVG Import/From File.html +0 -30
  415. package/examples/SVG Import/Gradient.html +0 -138
  416. package/examples/SVG Import/Gradients.html +0 -30
  417. package/examples/SVG Import/Inkscape Pivot.html +0 -52
  418. package/examples/SVG Import/Inkscape.html +0 -88
  419. package/examples/SVG Import/Line Testing.html +0 -24
  420. package/examples/SVG Import/MoreGradients.html +0 -107
  421. package/examples/SVG Import/Multiple Paths Test 1.html +0 -42
  422. package/examples/SVG Import/Multiple Paths Test 2.html +0 -33
  423. package/examples/SVG Import/Nested Groups Test.html +0 -78
  424. package/examples/SVG Import/Polybezier.html +0 -43
  425. package/examples/SVG Import/Rect Testing.html +0 -25
  426. package/examples/SVG Import/Symbols.html +0 -24
  427. package/examples/SVG Import/Testing.html +0 -40
  428. package/examples/SVG Import/Text Testing.html +0 -19
  429. package/examples/SVG Import/Tiger.html +0 -742
  430. package/examples/SVG Import/Transform Testing.html +0 -22
  431. package/examples/SVG Import/Viewbox.html +0 -38
  432. package/examples/Scripts/Arcs.html +0 -39
  433. package/examples/Scripts/AreaText.html +0 -65
  434. package/examples/Scripts/BlendModes.html +0 -77
  435. package/examples/Scripts/BooleanOperations.html +0 -937
  436. package/examples/Scripts/CompoundPath.html +0 -19
  437. package/examples/Scripts/CurveTimeParameterization.html +0 -61
  438. package/examples/Scripts/HslColor.html +0 -53
  439. package/examples/Scripts/PathStructure.html +0 -82
  440. package/examples/Scripts/PathTangents.html +0 -73
  441. package/examples/Scripts/PathText.html +0 -48
  442. package/examples/Scripts/Resize.html +0 -42
  443. package/examples/Scripts/RoundRectangle.html +0 -28
  444. package/examples/Scripts/Shapes.html +0 -54
  445. package/examples/Scripts/StrokeBounds.html +0 -101
  446. package/examples/Scripts/StrokeScaling.html +0 -65
  447. package/examples/Scripts/TextRanges.html +0 -51
  448. package/examples/Tools/BezierTool.html +0 -90
  449. package/examples/Tools/Circles.html +0 -28
  450. package/examples/Tools/Clouds.html +0 -35
  451. package/examples/Tools/DrippingBrush.html +0 -73
  452. package/examples/Tools/FancyBrush.html +0 -82
  453. package/examples/Tools/Grid.html +0 -44
  454. package/examples/Tools/MultiLines.html +0 -44
  455. package/examples/Tools/MultipleTools.html +0 -44
  456. package/examples/Tools/PathEditing.html +0 -95
  457. package/examples/Tools/SquareRounded.html +0 -76
  458. package/examples/Tools/Stars.html +0 -38
  459. package/examples/Tools/Vektor.html +0 -200
  460. package/examples/Tools/Wave.html +0 -50
  461. package/examples/Tools/WormFarm.html +0 -88
  462. package/examples/Worker/Main.html +0 -53
  463. package/examples/Worker/Worker.js +0 -14
  464. package/examples/css/style.css +0 -12
@@ -0,0 +1,748 @@
1
+ import { Item, Layer, Matrix, PaperScopeItem, PatternDefinition, Point, Style, SymbolDefinition, View } from '../internal.ts';
2
+ import type { PointLike } from '../basic/Point.ts';
3
+ import type { Hosting } from './hosting.ts';
4
+ import type { SizeLike } from '../basic/Size.ts';
5
+ import type { PaperScope } from '../scope/PaperScope.ts';
6
+ import type { HitResult } from './HitResult.ts';
7
+ import type { HitTestOptions } from './HitResult.ts';
8
+ import type { SVGExportOptions } from '../svg/svgExport.ts';
9
+ import type { SVGImportOptions } from '../svg/svgImport.ts';
10
+ import type { MatchOptions } from './query.ts';
11
+ import type { JSONDictionary, JSONOptions } from '../core/serialization.ts';
12
+ import type { EventHandler, EventType } from '../core/Emitter.ts';
13
+ type Handler = (this: Project, previous?: Project | null) => void;
14
+ export type ProjectChange = {
15
+ item?: Item;
16
+ definition?: SymbolDefinition | PatternDefinition;
17
+ flags: number;
18
+ reordered?: boolean;
19
+ };
20
+ /**
21
+ * A Project object in Paper.js is what usually is referred to as the document:
22
+ * The top level object that holds all the items contained in the scene graph.
23
+ * As the term document is already taken in the browser context, it is called
24
+ * Project.
25
+ *
26
+ * Projects allow the manipulation of the styles that are applied to all newly
27
+ * created items, give access to the selected items, and will in future versions
28
+ * offer ways to query for items in the scene graph defining specific
29
+ * requirements, and means to persist and load from different formats, such as
30
+ * SVG and PDF.
31
+ *
32
+ * The currently active project can be accessed through the
33
+ * {@link PaperScope#project} variable.
34
+ *
35
+ * An array of all open projects is accessible through the
36
+ * {@link PaperScope#projects} variable.
37
+ */
38
+ export declare class Project extends PaperScopeItem {
39
+ #private;
40
+ _compactSerialize: boolean;
41
+ _children: Layer[];
42
+ _namedChildren: Record<string, Layer[]>;
43
+ _activeLayer: Layer | null;
44
+ _currentStyle: Style;
45
+ _hosting: Hosting | null;
46
+ _view: View | null;
47
+ _selectionItems: Record<string, Item>;
48
+ _selectionCount: number;
49
+ _drawCount: number;
50
+ _updateVersion: number;
51
+ _bufferVersion: number;
52
+ _changes: ProjectChange[] | null;
53
+ _changesById: Record<string, ProjectChange> | null;
54
+ _removeSets: Record<string, Record<string, Item> | null>;
55
+ /**
56
+ * The function to be called when any project is activated, as
57
+ * {@link #onActivate} is for a single project, including the projects
58
+ * that activate themselves when they are created, with `this` set to the
59
+ * project. `Project.on('activate', handler)` and
60
+ * `Project.off('activate', handler)` attach and detach them too. Classes
61
+ * are shared by all {@link PaperScope} objects, and so are their handlers.
62
+ */
63
+ static onActivate: Handler | null;
64
+ /**
65
+ * The function to be called when any project is deactivated, as
66
+ * {@link #onDeactivate} is for a single project, see
67
+ * {@link Project.onActivate}.
68
+ */
69
+ static onDeactivate: Handler | null;
70
+ /**
71
+ * Creates a Paper.js project containing one empty {@link Layer}, referenced
72
+ * by {@link Project#activeLayer}.
73
+ *
74
+ * Note that when working with PaperScript, a project is automatically
75
+ * created for us and the {@link PaperScope#project} variable points to it.
76
+ *
77
+ * @param element the HTML canvas element that should be used as the element
78
+ * for the view, or an ID string by which to find the element, or the
79
+ * size of the canvas to be created for usage in a web worker.
80
+ */
81
+ constructor(element?: HTMLCanvasElement | string | SizeLike);
82
+ _serialize(options: JSONOptions, dictionary: JSONDictionary): any;
83
+ /**
84
+ * Private notifier that is called whenever a change occurs in the project.
85
+ *
86
+ * @param flags describes what exactly has changed
87
+ * @param item the item that has caused the change
88
+ */
89
+ _changed(flags: number, item?: Item): void;
90
+ _logChange(name: 'item' | 'definition', object: {
91
+ _id: number | string | null;
92
+ }, flags: number): void;
93
+ /**
94
+ * Specifies whether the project logs the changes of its items, to be
95
+ * retrieved through {@link #takeChanges()}. This allows hosts that keep
96
+ * their own document to update only what has changed.
97
+ *
98
+ * @default false
99
+ */
100
+ get trackChanges(): boolean;
101
+ set trackChanges(trackChanges: boolean);
102
+ /**
103
+ * Returns the changes logged since tracking was activated or since the
104
+ * last call, and clears the log. Each item is listed once, with the
105
+ * {@link ChangeFlag} values of all its changes combined. Removed items are
106
+ * listed with the `ChangeFlag.INSERTION` flag, and items that moved to
107
+ * another project are left out, as that one lists them. Symbol and pattern
108
+ * definitions whose item, tile, spacing or name changed are listed too,
109
+ * as `{ definition, flags }`.
110
+ *
111
+ * @return the changes as `{ item, flags }` and `{ definition, flags }`
112
+ * objects, or `null` if {@link #trackChanges} is off
113
+ */
114
+ takeChanges(): ProjectChange[] | null;
115
+ /**
116
+ * Checks whether changes were logged since tracking was activated or since
117
+ * the last call of {@link #takeChanges()}, without taking them.
118
+ *
119
+ * @return {@true if changes were logged}
120
+ */
121
+ hasChanges(): boolean;
122
+ /**
123
+ * Clears the project by removing all {@link Project#layers}.
124
+ */
125
+ clear(): void;
126
+ /**
127
+ * Checks whether the project has any content or not.
128
+ */
129
+ isEmpty(): boolean;
130
+ /**
131
+ * Removes this project from the {@link PaperScope#projects} list, and also
132
+ * removes its view, if one was defined.
133
+ *
134
+ * @return {@true if the project was removed}
135
+ */
136
+ remove(): boolean;
137
+ /**
138
+ * The reference to the project's view.
139
+ */
140
+ get view(): View;
141
+ /**
142
+ * The currently active path style. All selected items and newly
143
+ * created items will be styled with this style.
144
+ *
145
+ * @example {@paperscript}
146
+ * project.currentStyle = {
147
+ * fillColor: 'red',
148
+ * strokeColor: 'black',
149
+ * strokeWidth: 5
150
+ * }
151
+ *
152
+ * // The following paths will take over all style properties of
153
+ * // the current style:
154
+ * var path = Path.circle(new Point(75, 50), 30);
155
+ * var path2 = Path.circle(new Point(175, 50), 20);
156
+ *
157
+ * @example {@paperscript}
158
+ * project.currentStyle.fillColor = 'red';
159
+ *
160
+ * // The following path will take over the fill color we just set:
161
+ * var path = Path.circle(new Point(75, 50), 30);
162
+ * var path2 = Path.circle(new Point(175, 50), 20);
163
+ */
164
+ get currentStyle(): Style;
165
+ set currentStyle(style: Style | object);
166
+ /**
167
+ * The index of the project in the {@link PaperScope#projects} list.
168
+ */
169
+ get index(): number;
170
+ /**
171
+ * {@grouptitle Project Content}
172
+ *
173
+ * The layers contained within the project.
174
+ */
175
+ get layers(): Layer[];
176
+ /**
177
+ * The layer which is currently active. New items will be created on this
178
+ * layer by default.
179
+ */
180
+ get activeLayer(): Layer;
181
+ /**
182
+ * The symbol definitions shared by all symbol items contained in the
183
+ * project.
184
+ */
185
+ get symbolDefinitions(): SymbolDefinition[];
186
+ /**
187
+ * The pattern definitions that the fill and stroke colors of the items in
188
+ * the project use.
189
+ */
190
+ get patternDefinitions(): PatternDefinition[];
191
+ /**
192
+ * The selected items contained within the project, in the order they are
193
+ * drawn in, with groups before their children.
194
+ */
195
+ get selectedItems(): Item[];
196
+ _updateSelection(item: Item, remove?: boolean): void;
197
+ /**
198
+ * Selects all items in the project.
199
+ */
200
+ selectAll(): void;
201
+ /**
202
+ * Deselects all selected items in the project.
203
+ */
204
+ deselectAll(): void;
205
+ /**
206
+ * {@grouptitle Hierarchy Operations}
207
+ *
208
+ * Adds the specified layer at the end of this project's {@link #layers}
209
+ * list.
210
+ *
211
+ * @param layer the layer to be added to the project
212
+ * @return the added layer, or `null` if adding was not possible
213
+ */
214
+ addLayer(layer: Layer): Layer | null;
215
+ /**
216
+ * Inserts the specified layer at the specified index in this project's
217
+ * {@link #layers} list.
218
+ *
219
+ * @param index the index at which to insert the layer
220
+ * @param layer the layer to be inserted in the project
221
+ * @return the inserted layer, or `null` if inserting was not possible
222
+ */
223
+ insertLayer(index: number | undefined, layer: Layer): Layer | null;
224
+ _insertItem(index: number | undefined, item: Item, _created?: boolean): Item | null;
225
+ /**
226
+ * {@grouptitle Hit-testing, Fetching and Matching Items}
227
+ *
228
+ * Performs a hit-test on the items contained within the project at the
229
+ * location of the specified point.
230
+ *
231
+ * The options object allows you to control the specifics of the hit-test.
232
+ * Without options, `fill`, `stroke` and `segments` are hit-tested. As soon
233
+ * as an options object is passed, only the hit-tests that it sets to `true`
234
+ * are performed. It may contain a combination of the following values:
235
+ *
236
+ * @option [options.tolerance={@link PaperScope#settings}.hitTolerance]
237
+ * {Number} the tolerance of the hit-test, in project coordinates
238
+ * @option options.class {Function} only hit-test against a specific item
239
+ * class, or any of its sub-classes, by providing the constructor
240
+ * function against which an `instanceof` check is performed:
241
+ * {@values Group, Layer, Path, CompoundPath, Shape, Raster,
242
+ * SymbolItem, PointText, ...}
243
+ * @option options.match {Function} a match function to be called for each
244
+ * found hit result: Return `true` to return the result, `false` to keep
245
+ * searching
246
+ * @option options.fill {Boolean} hit-test the fill of items
247
+ * @option options.stroke {Boolean} hit-test the stroke of path items,
248
+ * taking into account the setting of stroke color and width
249
+ * @option options.segments {Boolean} hit-test for {@link Segment#point} of
250
+ * {@link Path} items
251
+ * @option options.curves {Boolean} hit-test the curves of path items,
252
+ * without taking the stroke color or width into account
253
+ * @option options.handles {Boolean} hit-test for the handles ({@link
254
+ * Segment#handleIn} / {@link Segment#handleOut}) of path segments.
255
+ * @option options.ends {Boolean} only hit-test for the first or last
256
+ * segment points of open path items
257
+ * @option options.position {Boolean} hit-test the {@link Item#position} of
258
+ * of items, which depends on the setting of {@link Item#pivot}
259
+ * @option options.center {Boolean} hit-test the {@link Rectangle#center} of
260
+ * the bounding rectangle of items ({@link Item#bounds})
261
+ * @option options.bounds {Boolean} hit-test the corners and side-centers of
262
+ * the bounding rectangle of items ({@link Item#bounds})
263
+ * @option options.guides {Boolean} only hit-test items that have {@link
264
+ * Item#guide} set to `true`
265
+ * @option options.selected {Boolean} only hit selected items
266
+ *
267
+ * @param point the point where the hit-test should be performed
268
+ * @param [options={ fill: true, stroke: true, segments: true,
269
+ * tolerance: settings.hitTolerance }]
270
+ * @return a hit result object that contains more information about what
271
+ * exactly was hit or `null` if nothing was hit
272
+ */
273
+ hitTest(point: PointLike, options?: HitTestOptions): HitResult | null;
274
+ /**
275
+ * Performs a hit-test on the items contained within the project at the
276
+ * location of the specified point, returning all found hits.
277
+ *
278
+ * The options object allows you to control the specifics of the hit-
279
+ * test. See {@link #hitTest(point[, options])} for a list of all options.
280
+ *
281
+ * @param point the point where the hit-test should be performed
282
+ * @param [options={ fill: true, stroke: true, segments: true,
283
+ * tolerance: settings.hitTolerance }]
284
+ * @return hit result objects for all hits, describing what exactly was
285
+ * hit, or an empty array if nothing was hit
286
+ * @see #hitTest(point[, options])
287
+ */
288
+ hitTestAll(point: PointLike, options?: HitTestOptions): HitResult[];
289
+ _hitTest(point: Point, options: HitTestOptions, viewMatrix?: Matrix | null): HitResult | null;
290
+ /**
291
+ *
292
+ * Fetch items contained within the project whose properties match the
293
+ * criteria in the specified object.
294
+ *
295
+ * Extended matching of properties is possible by providing a comparator
296
+ * function or regular expression. Matching points, colors only work as a
297
+ * comparison of the full object, not partial matching (e.g. only providing
298
+ * the x-coordinate to match all points with that x-value). Partial
299
+ * matching does work for {@link Item#data}.
300
+ *
301
+ * Matching items against a rectangular area is also possible, by setting
302
+ * either `options.inside` or `options.overlapping` to a rectangle
303
+ * describing the area in which the items either have to be fully or partly
304
+ * contained.
305
+ *
306
+ * @option [options.recursive=true] {Boolean} whether to loop recursively
307
+ * through all children, or stop at the current level
308
+ * @option options.match {Function} a match function to be called for each
309
+ * item, allowing the definition of more flexible item checks that are
310
+ * not bound to properties. If no other match properties are defined,
311
+ * this function can also be passed instead of the `match` object
312
+ * @option options.class {Function} the constructor function of the item
313
+ * type to match against
314
+ * @option options.inside {Rectangle} the rectangle in which the items need
315
+ * to be fully contained
316
+ * @option options.overlapping {Rectangle} the rectangle with which the
317
+ * items need to at least partly overlap
318
+ *
319
+ * @see Item#matches(options)
320
+ * @see Item#getItems(options)
321
+ * @param options the criteria to match against
322
+ * @return the list of matching items contained in the project, in their
323
+ * stacking order from bottom to top, with each item listed before its
324
+ * own descendants
325
+ *
326
+ * @example {@paperscript} // Fetch all selected path items:
327
+ * var path1 = Path.circle({
328
+ * center: [50, 50],
329
+ * radius: 25,
330
+ * fillColor: 'black'
331
+ * });
332
+ *
333
+ * var path2 = Path.circle({
334
+ * center: [150, 50],
335
+ * radius: 25,
336
+ * fillColor: 'black'
337
+ * });
338
+ *
339
+ * // Select path2:
340
+ * path2.selected = true;
341
+ *
342
+ * // Fetch all selected path items:
343
+ * var items = project.getItems({
344
+ * selected: true,
345
+ * class: Path
346
+ * });
347
+ *
348
+ * // Change the fill color of the selected path to red:
349
+ * items[0].fillColor = 'red';
350
+ *
351
+ * @example {@paperscript} // Fetch all items with a specific fill color:
352
+ * var path1 = Path.circle({
353
+ * center: [50, 50],
354
+ * radius: 25,
355
+ * fillColor: 'black'
356
+ * });
357
+ *
358
+ * var path2 = Path.circle({
359
+ * center: [150, 50],
360
+ * radius: 25,
361
+ * fillColor: 'purple'
362
+ * });
363
+ *
364
+ * // Fetch all items with a purple fill color:
365
+ * var items = project.getItems({
366
+ * fillColor: 'purple'
367
+ * });
368
+ *
369
+ * // Select the fetched item:
370
+ * items[0].selected = true;
371
+ *
372
+ * @example {@paperscript} // Fetch items at a specific position:
373
+ * var path1 = Path.circle({
374
+ * center: [50, 50],
375
+ * radius: 25,
376
+ * fillColor: 'black'
377
+ * });
378
+ *
379
+ * var path2 = Path.circle({
380
+ * center: [150, 50],
381
+ * radius: 25,
382
+ * fillColor: 'black'
383
+ * });
384
+ *
385
+ * // Fetch all path items positioned at {x: 150, y: 150}:
386
+ * var items = project.getItems({
387
+ * position: [150, 50]
388
+ * });
389
+ *
390
+ * // Select the fetched path:
391
+ * items[0].selected = true;
392
+ *
393
+ * @example {@paperscript} // Fetch items using a comparator function:
394
+ *
395
+ * // Create a circle shaped path:
396
+ * var path1 = Path.circle({
397
+ * center: [50, 50],
398
+ * radius: 25,
399
+ * fillColor: 'black'
400
+ * });
401
+ *
402
+ * // Create a circle shaped path with 50% opacity:
403
+ * var path2 = Path.circle({
404
+ * center: [150, 50],
405
+ * radius: 25,
406
+ * fillColor: 'black',
407
+ * opacity: 0.5
408
+ * });
409
+ *
410
+ * // Fetch all items whose opacity is smaller than 1
411
+ * var items = paper.project.getItems({
412
+ * opacity: function(value) {
413
+ * return value < 1;
414
+ * }
415
+ * });
416
+ *
417
+ * // Select the fetched item:
418
+ * items[0].selected = true;
419
+ *
420
+ * @example {@paperscript} // Fetch items using a comparator function (2):
421
+ *
422
+ * // Create a rectangle shaped path (4 segments):
423
+ * var path1 = Path.rectangle({
424
+ * from: [25, 25],
425
+ * to: [75, 75],
426
+ * strokeColor: 'black',
427
+ * strokeWidth: 10
428
+ * });
429
+ *
430
+ * // Create a line shaped path (2 segments):
431
+ * var path2 = Path.line({
432
+ * from: [125, 50],
433
+ * to: [175, 50],
434
+ * strokeColor: 'black',
435
+ * strokeWidth: 10
436
+ * });
437
+ *
438
+ * // Fetch all paths with 2 segments:
439
+ * var items = project.getItems({
440
+ * class: Path,
441
+ * segments: function(segments) {
442
+ * return segments.length == 2;
443
+ * }
444
+ * });
445
+ *
446
+ * // Select the fetched path:
447
+ * items[0].selected = true;
448
+ *
449
+ * @example {@paperscript} // Match (nested) properties of the data property:
450
+ *
451
+ * // Create a black circle shaped path:
452
+ * var path1 = Path.circle({
453
+ * center: [50, 50],
454
+ * radius: 25,
455
+ * fillColor: 'black',
456
+ * data: {
457
+ * person: {
458
+ * name: 'john',
459
+ * length: 200,
460
+ * hair: true
461
+ * }
462
+ * }
463
+ * });
464
+ *
465
+ * // Create a red circle shaped path:
466
+ * var path2 = Path.circle({
467
+ * center: [150, 50],
468
+ * radius: 25,
469
+ * fillColor: 'red',
470
+ * data: {
471
+ * person: {
472
+ * name: 'john',
473
+ * length: 180,
474
+ * hair: false
475
+ * }
476
+ * }
477
+ * });
478
+ *
479
+ * // Fetch all items whose data object contains a person
480
+ * // object whose name is john and length is 180:
481
+ * var items = paper.project.getItems({
482
+ * data: {
483
+ * person: {
484
+ * name: 'john',
485
+ * length: 180
486
+ * }
487
+ * }
488
+ * });
489
+ *
490
+ * // Select the fetched item:
491
+ * items[0].selected = true;
492
+ *
493
+ * @example {@paperscript} // Match strings using regular expressions:
494
+ *
495
+ * // Create a path named 'aardvark':
496
+ * var path1 = Path.circle({
497
+ * center: [50, 50],
498
+ * radius: 25,
499
+ * fillColor: 'black',
500
+ * name: 'aardvark'
501
+ * });
502
+ *
503
+ * // Create a path named 'apple':
504
+ * var path2 = Path.circle({
505
+ * center: [150, 50],
506
+ * radius: 25,
507
+ * fillColor: 'black',
508
+ * name: 'apple'
509
+ * });
510
+ *
511
+ * // Create a path named 'banana':
512
+ * var path2 = Path.circle({
513
+ * center: [250, 50],
514
+ * radius: 25,
515
+ * fillColor: 'black',
516
+ * name: 'banana'
517
+ * });
518
+ *
519
+ * // Fetch all items that have a name starting with 'a':
520
+ * var items = project.getItems({
521
+ * name: /^a/
522
+ * });
523
+ *
524
+ * // Change the fill color of the matched items:
525
+ * for (var i = 0; i < items.length; i++) {
526
+ * items[i].fillColor = 'red';
527
+ * }
528
+ */
529
+ getItems(options: MatchOptions | ((item: Item) => boolean)): Item[];
530
+ /**
531
+ * Fetch the first item contained within the project whose properties
532
+ * match the criteria in the specified object.
533
+ * Extended matching is possible by providing a compare function or
534
+ * regular expression. Matching points, colors only work as a comparison
535
+ * of the full object, not partial matching (e.g. only providing the
536
+ * x-coordinate to match all points with that x-value). Partial matching
537
+ * does work for {@link Item#data}.
538
+ *
539
+ * See {@link #getItems(options)} for a selection of illustrated examples.
540
+ *
541
+ * @param options the criteria to match against
542
+ * @return the first item in the project matching the given criteria
543
+ */
544
+ getItem(options: MatchOptions | ((item: Item) => boolean)): Item | null;
545
+ /**
546
+ * Imports (deserializes) the stored JSON data into the project.
547
+ * Note that the project is not cleared first. You can call
548
+ * {@link Project#clear()} to do so. In hosted projects, references to the
549
+ * definitions of the host, as `['@pattern/Dots']`, import as these
550
+ * definitions, see {@link #host}.
551
+ *
552
+ * @param json the JSON data to import from
553
+ * @return the imported item
554
+ */
555
+ importJSON(json: string | unknown[]): Item | Item[];
556
+ /**
557
+ * Exports the project with all its layers and child items as an SVG DOM,
558
+ * all contained in one top level SVG group node.
559
+ *
560
+ * @option [options.bounds='view'] {String|Rectangle} the bounds of the area
561
+ * to export, either as a string ({@values 'view', 'content'}), or a
562
+ * {@link Rectangle} object: `'view'` uses the view bounds,
563
+ * `'content'` uses the stroke bounds of all content
564
+ * @option [options.matrix=paper.view.matrix] {Matrix} the matrix with which
565
+ * to transform the exported content: If `options.bounds` is set to
566
+ * `'view'`, `paper.view.matrix` is used, for all other settings of
567
+ * `options.bounds` the identity matrix is used.
568
+ * @option [options.asString=false] {Boolean} whether a SVG node or a
569
+ * `String` is to be returned
570
+ * @option [options.precision=5] {Number} the amount of fractional digits in
571
+ * numbers used in SVG data
572
+ * @option [options.matchShapes=false] {Boolean} whether path items should
573
+ * be converted to SVG shape items (rect, circle, ellipse,
574
+ * line, polyline, polygon), if their geometries match
575
+ * @option [options.embedImages=true] {Boolean} whether raster images should
576
+ * be embedded as base64 data inlined in the xlink:href attribute, or
577
+ * kept as a link to their external URL.
578
+ * @option [options.reuseImages=false] {Boolean} whether raster images with
579
+ * the same content should only be exported once into the `<defs>`
580
+ * element, and placed through `<use>` elements referencing it
581
+ * @option [options.idPrefix=''] {String} a prefix for the ids generated
582
+ * for definitions such as gradients, clip paths and symbols, to keep
583
+ * them unique when several exported SVGs are placed in one document
584
+ * @option [options.reduceAttributes=true] {Boolean} whether to only include
585
+ * style attributes in the SVG output that differ from their parents,
586
+ * or to always include them (much faster but leading to redundancies).
587
+ * @option [options.processNode] {Function} the function to process the
588
+ * SVG node made for each exported item, receiving an object with the
589
+ * `item` and its `node`: It can change the node, e.g. to add attributes
590
+ * that Paper.js doesn't export, or return a node to replace it with. It
591
+ * is called before the item's name, style, visibility and data are set
592
+ * on the node, which replace attributes of the same names.
593
+ *
594
+ * @param [options] the export options
595
+ * @return the project converted to an SVG node or a `String`, depending
596
+ * on `options.asString`
597
+ *
598
+ * @example
599
+ * // Export layers as Inkscape layers. Setting the attributes with their
600
+ * // namespace has the exported SVG declare it:
601
+ * var ns = 'http://www.inkscape.org/namespaces/inkscape';
602
+ * var svg = project.exportSVG({
603
+ * asString: true,
604
+ * processNode: function(arg) {
605
+ * var item = arg.item;
606
+ * if (item instanceof Layer) {
607
+ * arg.node.setAttributeNS(ns, 'inkscape:groupmode', 'layer');
608
+ * if (item.name)
609
+ * arg.node.setAttributeNS(ns, 'inkscape:label', item.name);
610
+ * }
611
+ * }
612
+ * });
613
+ */
614
+ exportSVG(options?: SVGExportOptions): SVGElement | string;
615
+ /**
616
+ * Converts the provided SVG content into Paper.js items and adds them to
617
+ * the active layer of this project.
618
+ * Note that the project is not cleared first. You can call
619
+ * {@link Project#clear()} to do so.
620
+ *
621
+ * `<symbol>` elements are imported as {@link SymbolDefinition} items, and
622
+ * the `<use>` elements that place them as {@link SymbolItem} items. The
623
+ * styles that `<use>` elements inherit don't reach the symbols' content.
624
+ *
625
+ * The layers of SVG content that Paper.js exported become layers of this
626
+ * project again, and are returned as an array instead of a group, with
627
+ * the transformation of a zoomed or scrolled view that they were exported
628
+ * from. Content beside the layers goes into a layer of its own, below
629
+ * them. Layers inside other groups come back as {@link Layer} items inside
630
+ * the imported group.
631
+ *
632
+ * To load SVG from a URL or a file, see {@link #loadSVG(source)}.
633
+ *
634
+ * @option [options.expandShapes=false] {Boolean} whether imported shape
635
+ * items should be expanded to path items
636
+ * @option [options.crossOrigin] {String} the {@link Raster#crossOrigin}
637
+ * value of the rasters created for `<image>` elements, to load their
638
+ * images with CORS
639
+ * @option [options.insert=true] {Boolean} whether the imported items should
640
+ * be added to the project that `importSVG()` is called on
641
+ * @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
642
+ * {Boolean} whether the imported items should have their transformation
643
+ * matrices applied to their contents or not
644
+ * @option [options.processItem] {Function} the function to process the
645
+ * item made for each imported SVG element, receiving an object with
646
+ * the `item` and its `node`: It can read attributes that Paper.js
647
+ * doesn't import, or return an item to replace it with. It is called
648
+ * after the element's attributes and data are applied to the item, so
649
+ * it can extend `item.data`. A replacement item doesn't receive them:
650
+ * copy them over from `item` as needed.
651
+ *
652
+ * @param svg the SVG content to import, either as a SVG DOM node, a string
653
+ * containing SVG content, or the id of an SVG element in the document
654
+ * @param [options] the import options
655
+ * @return the newly created Paper.js item containing the converted SVG
656
+ * content, or its layers
657
+ *
658
+ * @example
659
+ * // Keep the SVG `class` attribute of items in their data, and export it
660
+ * // again:
661
+ * var item = project.importSVG(svg, {
662
+ * processItem: function(arg) {
663
+ * var className = arg.node.getAttribute('class');
664
+ * if (className)
665
+ * arg.item.data.className = className;
666
+ * }
667
+ * });
668
+ * var exported = project.exportSVG({
669
+ * processNode: function(arg) {
670
+ * var className = arg.item.data.className;
671
+ * if (className)
672
+ * arg.node.setAttribute('class', className);
673
+ * }
674
+ * });
675
+ */
676
+ importSVG(svg: SVGElement | string, options?: SVGImportOptions): Item | Layer[] | null;
677
+ /**
678
+ * Loads SVG from a URL or a file, and imports it as
679
+ * {@link #importSVG(svg)} does, with the same options.
680
+ *
681
+ * URLs are fetched as they are, so validate URLs that come from untrusted
682
+ * sources first, especially on servers, where they could reach internal
683
+ * addresses.
684
+ *
685
+ * @param source the URL of the SVG file to fetch, or a `File` to read,
686
+ * e.g. from a file input
687
+ * @param [options] the import options, see {@link #importSVG(svg)}
688
+ * @return a promise of the imported item, or its layers
689
+ *
690
+ * @example
691
+ * var item = await project.loadSVG('drawing.svg');
692
+ */
693
+ loadSVG(source: string | File, options?: SVGImportOptions): Promise<Item | Layer[] | null>;
694
+ removeOn(type: string): void;
695
+ draw(ctx: CanvasRenderingContext2D, matrix: Matrix, pixelRatio: number, _view?: View): void;
696
+ }
697
+ export interface Project {
698
+ /**
699
+ * Activates this project, so all newly created items will be placed
700
+ * in it.
701
+ *
702
+ * @return {@true if the project was activated}
703
+ */
704
+ activate(): boolean;
705
+ /**
706
+ * The function to be called when the project is activated through
707
+ * {@link #activate()}. The function receives the previously active
708
+ * project, which is the project itself when it was already active.
709
+ */
710
+ get onActivate(): Handler | null;
711
+ set onActivate(func: Handler | null);
712
+ /**
713
+ * The function to be called when another project is activated through
714
+ * {@link #activate()} while this one is active, or when this one is
715
+ * removed while active.
716
+ */
717
+ get onDeactivate(): Handler | null;
718
+ set onDeactivate(func: Handler | null);
719
+ on<K extends EventType<this>>(type: K, func: EventHandler<this, K>): this;
720
+ on(type: string, func: Handler): this;
721
+ once<K extends EventType<this>>(type: K, func: EventHandler<this, K>): this;
722
+ once(type: string, func: Handler): this;
723
+ /**
724
+ * The scope that this project belongs to.
725
+ *
726
+ * @readonly
727
+ */
728
+ get scope(): PaperScope;
729
+ /**
730
+ * {@grouptitle Importing / Exporting JSON and SVG}
731
+ *
732
+ * Exports (serializes) the project with all its layers and child items to a
733
+ * JSON data object or string.
734
+ *
735
+ * @option [options.asString=true] {Boolean} whether the JSON is returned as
736
+ * an `Object` or a `String`
737
+ * @option [options.precision=5] {Number} the amount of fractional digits in
738
+ * numbers used in JSON data
739
+ *
740
+ * @param [options] the serialization options
741
+ * @return the exported JSON data
742
+ */
743
+ exportJSON(options?: {
744
+ asString?: boolean;
745
+ precision?: number;
746
+ }): string | unknown[];
747
+ }
748
+ export {};