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,700 @@
1
+ import { CanvasView, Emitter, Item, KeyEvent, Matrix, MouseEvent, PaperScope, Point, Rectangle, Size, ViewInput } from '../internal.ts';
2
+ import type { EventHandler, EventHandlers, EventType } from '../core/Emitter.ts';
3
+ import type { PointLike } from '../basic/Point.ts';
4
+ import type { SizeLike } from '../basic/Size.ts';
5
+ import type { RectangleLike } from '../basic/Rectangle.ts';
6
+ import type { Project } from '../item/Project.ts';
7
+ import type { Key } from '../event/Key.ts';
8
+ export type DispatchOptions = {
9
+ modifiers?: Partial<typeof Key.modifiers>;
10
+ time?: number;
11
+ };
12
+ export type PointerOptions = {
13
+ button?: number;
14
+ buttons?: number;
15
+ pointerType?: 'mouse' | 'touch' | 'pen';
16
+ pressure?: number;
17
+ };
18
+ type Handler = (this: View, ...args: any[]) => any;
19
+ type MouseHandler = ((this: View, event: MouseEvent<Item | View>) => any) | null;
20
+ type KeyHandler = ((this: View, event: KeyEvent) => any) | null;
21
+ export type FrameEvent = {
22
+ delta: number;
23
+ time: number;
24
+ count: number;
25
+ };
26
+ /**
27
+ * The View object wraps an HTML element and handles drawing and user
28
+ * interaction through mouse and keyboard for it. It offers means to scroll the
29
+ * view, find the currently visible bounds in project coordinates, or the
30
+ * center, both useful for constructing artwork that should appear centered on
31
+ * screen.
32
+ *
33
+ * If the canvas element has a `resize` or `data-paper-resize` attribute, the
34
+ * view adjusts its size to the size of the element whenever the window is
35
+ * resized. The element itself needs to be sized through CSS, e.g. with
36
+ * `html, body { height: 100%; }` and `canvas[resize] { width: 100%; height:
37
+ * 100%; }` for a canvas that fills the window. Without such CSS, the view does
38
+ * not follow the window, and on HiDPI screens it grows with each resize.
39
+ * Without the attribute, the view sets the element's CSS width and height to
40
+ * its own size, see {@link #viewSize}.
41
+ *
42
+ * If the canvas element has an `input="off"` or `data-paper-input="off"`
43
+ * attribute, the view doesn't handle the user's input: it installs no
44
+ * listeners for the pointer and the keyboard, and never takes the keyboard's
45
+ * focus. Its drawing, {@link #onFrame}, {@link #onResize}, hit-tests and
46
+ * {@link #dispatchMouseEvent()} work as before.
47
+ */
48
+ export declare class View extends Emitter {
49
+ #private;
50
+ static _focused: View | null;
51
+ _project: Project | null;
52
+ _element: HTMLCanvasElement | null;
53
+ _context: CanvasRenderingContext2D | null;
54
+ _pixelRatio: number;
55
+ _viewSize: Size;
56
+ _matrix: Matrix;
57
+ _autoUpdate: boolean;
58
+ _needsUpdate: boolean;
59
+ _requested: boolean;
60
+ _hasInput: boolean;
61
+ _input: ViewInput;
62
+ constructor(project: Project, element: HTMLCanvasElement | SizeLike);
63
+ /**
64
+ * Removes this view from the project and frees the associated element.
65
+ */
66
+ remove(): boolean;
67
+ /**
68
+ * Controls whether the view is automatically updated in the next animation
69
+ * frame on changes, or whether you prefer to manually call
70
+ * {@link #update()} or {@link #requestUpdate()} after changes.
71
+ * Note that this is `true` by default, except for Node.js, where manual
72
+ * updates make more sense.
73
+ */
74
+ get autoUpdate(): boolean;
75
+ set autoUpdate(autoUpdate: boolean);
76
+ /**
77
+ * Updates the view if there are changes. Note that when using built-in
78
+ * event handlers for interaction, animation and load events, this method is
79
+ * invoked for you automatically at the end.
80
+ *
81
+ * @param [force=false] whether to redraw the view even if nothing
82
+ * has changed, e.g. after a web font used by text items has finished
83
+ * loading, also in buffered groups, see {@link Group#buffered}
84
+ * @return {@true if the view was updated}
85
+ */
86
+ update(force?: boolean): boolean;
87
+ /**
88
+ * Requests an update of the view if there are changes through the browser's
89
+ * requestAnimationFrame() mechanism for smooth animation. Note that when
90
+ * using built-in event handlers for interaction, animation and load events,
91
+ * updates are invoked for you automatically at the end.
92
+ */
93
+ requestUpdate(): void;
94
+ /**
95
+ * Makes all animation play by adding the view to the request animation
96
+ * loop.
97
+ */
98
+ play(): void;
99
+ /**
100
+ * Makes all animation pause by removing the view from the request animation
101
+ * loop.
102
+ */
103
+ pause(): void;
104
+ _animateItem(item: Item, animate: boolean): void;
105
+ _matrixChanged(): void;
106
+ _changed(): void;
107
+ /**
108
+ * The underlying native element.
109
+ */
110
+ get element(): HTMLCanvasElement | null;
111
+ /**
112
+ * The project that this view displays.
113
+ */
114
+ get project(): Project | null;
115
+ /**
116
+ * The scope that this view belongs to.
117
+ */
118
+ get scope(): PaperScope;
119
+ /**
120
+ * The ratio between physical pixels and device-independent pixels (DIPs)
121
+ * of the underlying canvas / device.
122
+ * It is `1` for normal displays, and `2` or more for
123
+ * high-resolution displays.
124
+ */
125
+ get pixelRatio(): number;
126
+ /**
127
+ * The resolution of the underlying canvas / device in pixel per inch (DPI).
128
+ * It is `72` for normal displays, and `144` for high-resolution
129
+ * displays with a pixel-ratio of `2`.
130
+ */
131
+ get resolution(): number;
132
+ /**
133
+ * The size of the view. Changing the view's size will resize its
134
+ * underlying element.
135
+ */
136
+ get viewSize(): Size;
137
+ set viewSize(size: SizeLike);
138
+ /**
139
+ * Private method, overridden in CanvasView for HiDPI support.
140
+ */
141
+ _setElementSize(width: number, height: number): void;
142
+ /**
143
+ * The bounds of the currently visible area in project coordinates.
144
+ * Setting them fits the view to the given rectangle, as
145
+ * {@link #fitBounds(rectangle)} does. Since the view keeps its aspect
146
+ * ratio, the bounds read back can be larger than the rectangle in one
147
+ * direction.
148
+ */
149
+ get bounds(): Rectangle;
150
+ set bounds(rect: RectangleLike);
151
+ /**
152
+ * The size of the visible area in project coordinates.
153
+ */
154
+ get size(): Size;
155
+ /**
156
+ * Checks whether the view is currently visible within the current browser
157
+ * viewport.
158
+ *
159
+ * @return {@true if the view is visible}
160
+ */
161
+ isVisible(): boolean;
162
+ /**
163
+ * Checks whether the view is inserted into the browser DOM.
164
+ *
165
+ * @return {@true if the view is inserted}
166
+ */
167
+ isInserted(): boolean;
168
+ /**
169
+ * {@grouptitle Transform Functions}
170
+ *
171
+ * Translates (scrolls) the view by the given offset vector.
172
+ *
173
+ * @param delta the offset to translate the view by, or one distance for
174
+ * both directions
175
+ */
176
+ translate(delta: PointLike | number, y?: number): void;
177
+ /**
178
+ * The center of the visible area in project coordinates.
179
+ */
180
+ get center(): Point;
181
+ set center(center: PointLike);
182
+ /**
183
+ * The view's zoom factor by which the project coordinates are magnified.
184
+ * Setting it to a value that isn't a positive number has no effect.
185
+ *
186
+ * @see #scaling
187
+ */
188
+ get zoom(): number;
189
+ set zoom(zoom: number);
190
+ /**
191
+ * The current rotation angle of the view, as described by its
192
+ * {@link #matrix}.
193
+ */
194
+ get rotation(): number;
195
+ set rotation(rotation: number);
196
+ /**
197
+ * The current scale factor of the view, as described by its
198
+ * {@link #matrix}.
199
+ *
200
+ * @see #zoom
201
+ */
202
+ get scaling(): Point;
203
+ set scaling(scaling: PointLike | number);
204
+ /**
205
+ * The view's transformation matrix, defining the view onto the project's
206
+ * contents (position, zoom level, rotation, etc).
207
+ */
208
+ get matrix(): Matrix;
209
+ set matrix(matrix: Matrix | number[]);
210
+ /**
211
+ * Transform the view.
212
+ *
213
+ * @param matrix the matrix by which the view shall be transformed
214
+ */
215
+ transform(matrix: Matrix): void;
216
+ /**
217
+ * Rotates the view by a given angle around the given center point.
218
+ *
219
+ * Angles are oriented clockwise and measured in degrees.
220
+ *
221
+ * @param angle the rotation angle
222
+ * @param [center={@link View#center}]
223
+ * @see Matrix#rotate(angle[, center])
224
+ */
225
+ rotate(angle: number, center?: PointLike): void;
226
+ /**
227
+ * Scales the view by the given value from its center point, or optionally
228
+ * from a supplied point.
229
+ *
230
+ * @param scale the scale factor
231
+ * @param [center={@link View#center}]
232
+ */
233
+ scale(scale: PointLike | number, center?: PointLike): void;
234
+ /**
235
+ * Scales the view by the given values from its center point, or optionally
236
+ * from a supplied point.
237
+ *
238
+ * @param hor the horizontal scale factor
239
+ * @param ver the vertical scale factor
240
+ * @param [center={@link View#center}]
241
+ */
242
+ scale(hor: number, ver: number, center?: PointLike): void;
243
+ /**
244
+ * Shears the view by the given value from its center point, or optionally
245
+ * by a supplied point.
246
+ *
247
+ * @param shear the horizontal and vertical shear factors as a point
248
+ * @param [center={@link View#center}]
249
+ * @see Matrix#shear(shear[, center])
250
+ */
251
+ shear(shear: PointLike | number, center?: PointLike): void;
252
+ /**
253
+ * Shears the view by the given values from its center point, or optionally
254
+ * by a supplied point.
255
+ *
256
+ * @param hor the horizontal shear factor
257
+ * @param ver the vertical shear factor
258
+ * @param [center={@link View#center}]
259
+ * @see Matrix#shear(hor, ver[, center])
260
+ */
261
+ shear(hor: number, ver: number, center?: PointLike): void;
262
+ /**
263
+ * Skews the view by the given angles from its center point, or optionally
264
+ * by a supplied point.
265
+ *
266
+ * @param skew the horizontal and vertical skew angles in degrees
267
+ * @param [center={@link View#center}]
268
+ * @see Matrix#skew(skew[, center])
269
+ */
270
+ skew(skew: PointLike | number, center?: PointLike): void;
271
+ /**
272
+ * Skews the view by the given angles from its center point, or optionally
273
+ * by a supplied point.
274
+ *
275
+ * @param hor the horizontal skew angle in degrees
276
+ * @param ver the vertical skew angle in degrees
277
+ * @param [center={@link View#center}]
278
+ * @see Matrix#skew(hor, ver[, center])
279
+ */
280
+ skew(hor: number, ver: number, center?: PointLike): void;
281
+ /**
282
+ * Transform the view so that the specified rectangle is centered in it
283
+ * and fitted to it as described by `fit`, keeping the view's rotation and
284
+ * mirroring.
285
+ *
286
+ * @param rectangle the rectangle to fit, in project
287
+ * coordinates
288
+ * @param [fit='contain'] how to fit the rectangle, as in CSS's
289
+ * `object-fit`: `'contain'` shows all of it, and `'cover'` fills the
290
+ * whole view with it, cropping the parts that don't fit
291
+ *
292
+ * @example {@paperscript height=100}
293
+ * // Fitting the view to the bounds of an item:
294
+ *
295
+ * // Create a circle shaped path around the top left corner of the view:
296
+ * var path = Path.circle({
297
+ * center: [0, 0],
298
+ * radius: 50,
299
+ * fillColor: 'orange'
300
+ * });
301
+ *
302
+ * // Make the view show the whole circle:
303
+ * view.fitBounds(path.bounds);
304
+ */
305
+ fitBounds(rectangle: RectangleLike, fit?: 'contain' | 'cover'): void;
306
+ /**
307
+ * Converts the passed point from project coordinate space to view
308
+ * coordinate space, which is measured in browser pixels in relation to the
309
+ * position of the view element.
310
+ *
311
+ * @param point the point in project coordinates to be converted
312
+ * @return the point converted into view coordinates
313
+ */
314
+ projectToView(point: PointLike | number, y?: number): Point;
315
+ /**
316
+ * Converts the passed point from view coordinate space to project
317
+ * coordinate space.
318
+ *
319
+ * @param point the point in view coordinates to be converted
320
+ * @return the point converted into project coordinates
321
+ */
322
+ viewToProject(point: PointLike | number, y?: number): Point;
323
+ /**
324
+ * Determines and returns the event location in project coordinate space.
325
+ *
326
+ * @param event the native event object for which to determine the
327
+ * location.
328
+ * @return the event point in project coordinates.
329
+ */
330
+ getEventPoint(event: globalThis.MouseEvent): Point;
331
+ /**
332
+ * Handles a mouse event that the host provides, for hosts without a
333
+ * DOM, such as workers, or with their own event source. It runs the
334
+ * same handling as the DOM's mouse events: the active tool's handlers,
335
+ * with {@link Tool#minDistance} and the like, then those of the items
336
+ * under the point and of the view, including the events that Paper.js
337
+ * derives itself: `'mousedrag'`, `'click'`, `'doubleclick'`,
338
+ * `'mouseenter'` and `'mouseleave'`. Points outside the view's bounds
339
+ * are handled too, since the host decides which events belong to its
340
+ * drawing surface.
341
+ *
342
+ * @option [options.modifiers] {Object} the state of the modifier keys,
343
+ * see {@link Key.modifiers}
344
+ * @option [options.button=0] {Number} the mouse button, see
345
+ * {@link MouseEvent#button}
346
+ * @option [options.buttons] {Number} the buttons that are down, see
347
+ * {@link MouseEvent#buttons}. By default, the main button from
348
+ * mousedown to mouseup
349
+ * @option [options.pointerType='mouse'] {String} the kind of pointer:
350
+ * {@values 'mouse', 'touch', 'pen'}
351
+ * @option [options.pressure] {Number} the pressure of the pointer, see
352
+ * {@link MouseEvent#pressure}
353
+ * @option [options.time=Date.now() / 1000] {Number} the time of the
354
+ * event in seconds, see {@link Event#time}
355
+ *
356
+ * @param type the type of the event: {@values 'mousedown',
357
+ * 'mousemove', 'mouseup'}
358
+ * @param point the location of the mouse in project coordinates
359
+ * @param [options] the details of the event
360
+ * @return {@true if a handler prevented the event's default}
361
+ */
362
+ dispatchMouseEvent(type: 'mousedown' | 'mousemove' | 'mouseup', point: PointLike, options?: DispatchOptions & PointerOptions): boolean;
363
+ /**
364
+ * Handles a key event that the host provides, for hosts without a DOM,
365
+ * such as workers, or with their own event source. It updates
366
+ * {@link Key.modifiers} and {@link Key.isDown(key)}, and calls the
367
+ * view's and the active tool's handlers, as the DOM's key events do.
368
+ *
369
+ * @option [options.character] {String} the character that the key
370
+ * produces. By default, keydown takes the key itself if it is a
371
+ * single character, the space, carriage return and tab characters
372
+ * for 'space', 'enter' and 'tab', and keyup the character of its
373
+ * keydown
374
+ * @option [options.modifiers] {Object} the state of the modifier keys,
375
+ * see {@link Key.modifiers}
376
+ * @option [options.time=Date.now() / 1000] {Number} the time of the
377
+ * event in seconds, see {@link Event#time}
378
+ *
379
+ * @param type the type of the event: {@values 'keydown',
380
+ * 'keyup'}
381
+ * @param key the key, as in {@link KeyEvent#key}
382
+ * @param [options] the details of the event
383
+ * @return {@true if a handler prevented the event's default}
384
+ */
385
+ dispatchKeyEvent(type: 'keydown' | 'keyup', key: string, options?: DispatchOptions & {
386
+ character?: string;
387
+ }): boolean;
388
+ static _canvasView: typeof CanvasView | undefined;
389
+ static create(project: Project, element: HTMLCanvasElement | OffscreenCanvas | string | SizeLike | null): View;
390
+ /**
391
+ * Loops through all views and sets the focus on the first
392
+ * active one.
393
+ */
394
+ static updateFocus(): void;
395
+ /**
396
+ * Clear the focus that the views share, as each view's input keeps the
397
+ * rest of the state of the events. Made for testing purpose, to have a way to start
398
+ * with a fresh state before each test.
399
+ *
400
+ * @private
401
+ */
402
+ static _resetState(): void;
403
+ }
404
+ export interface View {
405
+ /**
406
+ * {@grouptitle Event Handlers}
407
+ * Handler function to be called on each frame of an animation.
408
+ * The function receives an event object which contains information about
409
+ * the frame event:
410
+ *
411
+ * @option event.count {Number} the number of times the frame event was
412
+ * fired
413
+ * @option event.time {Number} the total amount of time passed since the
414
+ * first frame event in seconds
415
+ * @option event.delta {Number} the time passed in seconds since the last
416
+ * frame event
417
+ *
418
+ * @see Item#onFrame
419
+ *
420
+ * @example {@paperscript}
421
+ * // Creating an animation:
422
+ *
423
+ * // Create a rectangle shaped path with its top left point at:
424
+ * // {x: 50, y: 25} and a size of {width: 50, height: 50}
425
+ * var path = Path.rectangle(new Point(50, 25), new Size(50, 50));
426
+ * path.fillColor = 'black';
427
+ *
428
+ * view.onFrame = function(event) {
429
+ * // Every frame, rotate the path by 3 degrees:
430
+ * path.rotate(3);
431
+ * }
432
+ */
433
+ onFrame: ((this: View, event: FrameEvent) => any) | null;
434
+ /**
435
+ * Handler function that is called whenever a view is resized.
436
+ *
437
+ * @example
438
+ * // Repositioning items when a view is resized:
439
+ *
440
+ * // Create a circle shaped path in the center of the view:
441
+ * var path = Path.circle(view.bounds.center, 30);
442
+ * path.fillColor = 'red';
443
+ *
444
+ * view.onResize = function(event) {
445
+ * // Whenever the view is resized, move the path to its center:
446
+ * path.position = view.center;
447
+ * }
448
+ */
449
+ onResize: ((this: View, event: {
450
+ size: Size;
451
+ delta: Size;
452
+ }) => any) | null;
453
+ /**
454
+ * The function to be called when the mouse button is pushed down on the
455
+ * view. The function receives a {@link MouseEvent} object which contains
456
+ * information about the mouse event.
457
+ * Note that such mouse events bubble up the scene graph hierarchy, reaching
458
+ * the view at the end, unless they are stopped before with {@link
459
+ * Event#stopPropagation()} or by returning `false` from a handler.
460
+ *
461
+ * @see Item#onMouseDown
462
+ */
463
+ onMouseDown: MouseHandler;
464
+ /**
465
+ * The function to be called when the mouse position changes while the mouse
466
+ * is being dragged over the view. The function receives a {@link
467
+ * MouseEvent} object which contains information about the mouse event.
468
+ * Note that such mouse events bubble up the scene graph hierarchy, reaching
469
+ * the view at the end, unless they are stopped before with {@link
470
+ * Event#stopPropagation()} or by returning `false` from a handler.
471
+ *
472
+ * @see Item#onMouseDrag
473
+ */
474
+ onMouseDrag: MouseHandler;
475
+ /**
476
+ * The function to be called when the mouse button is released over the view.
477
+ * The function receives a {@link MouseEvent} object which contains
478
+ * information about the mouse event.
479
+ *
480
+ * @see Item#onMouseUp
481
+ */
482
+ onMouseUp: MouseHandler;
483
+ /**
484
+ * The function to be called when the mouse clicks on the view. The function
485
+ * receives a {@link MouseEvent} object which contains information about the
486
+ * mouse event.
487
+ * Note that such mouse events bubble up the scene graph hierarchy, reaching
488
+ * the view at the end, unless they are stopped before with {@link
489
+ * Event#stopPropagation()} or by returning `false` from a handler.
490
+ *
491
+ * @see Item#onClick
492
+ */
493
+ onClick: MouseHandler;
494
+ /**
495
+ * The function to be called when the mouse double clicks on the view. The
496
+ * function receives a {@link MouseEvent} object which contains information
497
+ * about the mouse event.
498
+ * Note that such mouse events bubble up the scene graph hierarchy, reaching
499
+ * the view at the end, unless they are stopped before with {@link
500
+ * Event#stopPropagation()} or by returning `false` from a handler.
501
+ *
502
+ * @see Item#onDoubleClick
503
+ */
504
+ onDoubleClick: MouseHandler;
505
+ /**
506
+ * The function to be called repeatedly while the mouse moves over the
507
+ * view. The function receives a {@link MouseEvent} object which contains
508
+ * information about the mouse event.
509
+ * Note that such mouse events bubble up the scene graph hierarchy, reaching
510
+ * the view at the end, unless they are stopped before with {@link
511
+ * Event#stopPropagation()} or by returning `false` from a handler.
512
+ *
513
+ * @see Item#onMouseMove
514
+ */
515
+ onMouseMove: MouseHandler;
516
+ /**
517
+ * The function to be called when the mouse moves over the view. This
518
+ * function will only be called again, once the mouse moved outside of the
519
+ * view first. The function receives a {@link MouseEvent} object which
520
+ * contains information about the mouse event.
521
+ * Note that such mouse events bubble up the scene graph hierarchy, reaching
522
+ * the view at the end, unless they are stopped before with {@link
523
+ * Event#stopPropagation()} or by returning `false` from a handler.
524
+ *
525
+ * @see Item#onMouseEnter
526
+ */
527
+ onMouseEnter: MouseHandler;
528
+ /**
529
+ * The function to be called when the mouse moves out of the view.
530
+ * The function receives a {@link MouseEvent} object which contains
531
+ * information about the mouse event.
532
+ * Note that such mouse events bubble up the scene graph hierarchy, reaching
533
+ * the view at the end, unless they are stopped before with {@link
534
+ * Event#stopPropagation()} or by returning `false` from a handler.
535
+ *
536
+ * @see Item#onMouseLeave
537
+ */
538
+ onMouseLeave: MouseHandler;
539
+ /**
540
+ * The function to be called when the user presses a key on the keyboard.
541
+ * The function receives a {@link KeyEvent} object which contains
542
+ * information about the keyboard event.
543
+ *
544
+ * If the function returns `false`, the keyboard event will be prevented
545
+ * from bubbling up. This can be used for example to stop the window from
546
+ * scrolling, when you need the user to interact with arrow keys.
547
+ *
548
+ * @example {@paperscript}
549
+ * // Scaling a path whenever the user presses the space bar:
550
+ *
551
+ * // Create a circle shaped path:
552
+ * var path = Path.circle({
553
+ * center: new Point(50, 50),
554
+ * radius: 30,
555
+ * fillColor: 'red'
556
+ * });
557
+ *
558
+ * view.onKeyDown = function(event) {
559
+ * if (event.key == 'space') {
560
+ * // Scale the path by 110%:
561
+ * path.scale(1.1);
562
+ *
563
+ * // Prevent the key event from bubbling
564
+ * return false;
565
+ * }
566
+ * }
567
+ */
568
+ onKeyDown: KeyHandler;
569
+ /**
570
+ * The function to be called when the user releases a key on the keyboard.
571
+ * The function receives a {@link KeyEvent} object which contains
572
+ * information about the keyboard event.
573
+ *
574
+ * If the function returns `false`, the keyboard event will be prevented
575
+ * from bubbling up. This can be used for example to stop the window from
576
+ * scrolling, when you need the user to interact with arrow keys.
577
+ *
578
+ * @example
579
+ * view.onKeyUp = function(event) {
580
+ * if (event.key == 'space') {
581
+ * console.log('The spacebar was released!');
582
+ * }
583
+ * }
584
+ */
585
+ onKeyUp: KeyHandler;
586
+ /**
587
+ * {@grouptitle Event Handling}
588
+ *
589
+ * Attach an event handler to the view.
590
+ *
591
+ * @param type the type of event: {@values 'frame', 'resize',
592
+ * 'mousedown', 'mouseup', 'mousedrag', 'click', 'doubleclick',
593
+ * 'mousemove', 'mouseenter', 'mouseleave'}
594
+ * @param func the function to be called when the event
595
+ * occurs, receiving a {@link MouseEvent} or {@link Event} object as its
596
+ * sole argument
597
+ * @return this view itself, so calls can be chained
598
+ *
599
+ * @example {@paperscript}
600
+ * // Create a rectangle shaped path with its top left point at:
601
+ * // {x: 50, y: 25} and a size of {width: 50, height: 50}
602
+ * var path = Path.rectangle(new Point(50, 25), new Size(50, 50));
603
+ * path.fillColor = 'black';
604
+ *
605
+ * var frameHandler = function(event) {
606
+ * // Every frame, rotate the path by 3 degrees:
607
+ * path.rotate(3);
608
+ * };
609
+ *
610
+ * view.on('frame', frameHandler);
611
+ */
612
+ on<K extends EventType<this>>(type: K, func: EventHandler<this, K>): this;
613
+ on(type: string, func: Handler): this;
614
+ /**
615
+ * Attach one or more event handlers to the view.
616
+ *
617
+ * @param param an object literal containing one or more of the
618
+ * following properties: {@values frame, resize}
619
+ * @return this view itself, so calls can be chained
620
+ *
621
+ * @example {@paperscript}
622
+ * // Create a rectangle shaped path with its top left point at:
623
+ * // {x: 50, y: 25} and a size of {width: 50, height: 50}
624
+ * var path = Path.rectangle(new Point(50, 25), new Size(50, 50));
625
+ * path.fillColor = 'black';
626
+ *
627
+ * var frameHandler = function(event) {
628
+ * // Every frame, rotate the path by 3 degrees:
629
+ * path.rotate(3);
630
+ * };
631
+ *
632
+ * view.on({
633
+ * frame: frameHandler
634
+ * });
635
+ */
636
+ on(param: EventHandlers<this, Handler>): this;
637
+ once<K extends EventType<this>>(type: K, func: EventHandler<this, K>): this;
638
+ once(type: string, func: Handler): this;
639
+ /**
640
+ * Detach an event handler from the view.
641
+ *
642
+ * @param type the event type: {@values 'frame', 'resize',
643
+ * 'mousedown', 'mouseup', 'mousedrag', 'click', 'doubleclick',
644
+ * 'mousemove', 'mouseenter', 'mouseleave'}
645
+ * @param func the function to be detached
646
+ * @return this view itself, so calls can be chained
647
+ *
648
+ * @example {@paperscript}
649
+ * // Create a rectangle shaped path with its top left point at:
650
+ * // {x: 50, y: 25} and a size of {width: 50, height: 50}
651
+ * var path = Path.rectangle(new Point(50, 25), new Size(50, 50));
652
+ * path.fillColor = 'black';
653
+ *
654
+ * var frameHandler = function(event) {
655
+ * // Every frame, rotate the path by 3 degrees:
656
+ * path.rotate(3);
657
+ * };
658
+ *
659
+ * view.on({
660
+ * frame: frameHandler
661
+ * });
662
+ *
663
+ * // When the user presses the mouse,
664
+ * // detach the frame handler from the view:
665
+ * function onMouseDown(event) {
666
+ * view.off('frame');
667
+ * }
668
+ */
669
+ off(type: string, func?: Handler): this;
670
+ /**
671
+ * Detach one or more event handlers from the view.
672
+ *
673
+ * @param param an object literal containing one or more of the
674
+ * following properties: {@values frame, resize}
675
+ * @return this view itself, so calls can be chained
676
+ */
677
+ off(param: EventHandlers<this, Handler>): this;
678
+ /**
679
+ * Emit an event on the view.
680
+ *
681
+ * @param type the event type: {@values 'frame', 'resize',
682
+ * 'mousedown', 'mouseup', 'mousedrag', 'click', 'doubleclick',
683
+ * 'mousemove', 'mouseenter', 'mouseleave'}
684
+ * @param event an object literal containing properties describing
685
+ * the event
686
+ * @return {@true if the event had listeners}
687
+ */
688
+ emit(type: string, event?: unknown): boolean;
689
+ /**
690
+ * Check if the view has one or more event handlers of the specified type.
691
+ *
692
+ * @param type the event type: {@values 'frame', 'resize',
693
+ * 'mousedown', 'mouseup', 'mousedrag', 'click', 'doubleclick',
694
+ * 'mousemove', 'mouseenter', 'mouseleave'}
695
+ * @return {@true if the view has one or more event handlers of
696
+ * the specified type}
697
+ */
698
+ responds(type: string): boolean;
699
+ }
700
+ export {};