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,1361 @@
1
+ import { Curve, CurveLocation, HitResult, Matrix, PathItem, Point, Rectangle, Segment, Shape, StrokeProfile, StrokeProfileStop } from '../internal.ts';
2
+ import type { ItemProps } from '../item/props.ts';
3
+ import type { PointLike } from '../basic/Point.ts';
4
+ import type { CubicCoordinates, QuadraticCoordinates } from './PathItem.ts';
5
+ import type { Project } from '../item/Project.ts';
6
+ import type { SizeLike } from '../basic/Size.ts';
7
+ import type { RectangleLike } from '../basic/Rectangle.ts';
8
+ import type { Style } from '../style/Style.ts';
9
+ import type { SegmentLike } from './Segment.ts';
10
+ import type { PathProps, RectangleProps } from './shapes.ts';
11
+ import type { PathSimplifyOptions, PathSmoothOptions } from './smooth.ts';
12
+ import type { StrokeProfileStopProps } from './StrokeProfileStop.ts';
13
+ import type { DrawParam } from '../item/draw.ts';
14
+ import type { HitTestOptions } from '../item/HitResult.ts';
15
+ import type { BoundsOptions, TransformOptions } from '../item/Item.ts';
16
+ /**
17
+ * The path item represents a path in a Paper.js project. Paths are created
18
+ * with `new Path()` or {@link PathItem.create(segments)}, and shapes with
19
+ * factories such as {@link Path.circle(center, radius)}. Unless their
20
+ * {@link Item#applyMatrix} is turned off, paths apply transformations to
21
+ * their segments right away, so their {@link Item#matrix} stays the identity.
22
+ */
23
+ export declare class Path extends PathItem {
24
+ _segments: Segment[];
25
+ _closed: boolean;
26
+ _version: number;
27
+ _curves: Curve[] | undefined;
28
+ _segmentSelection: number;
29
+ _namedSegments: Record<string, Segment[]> | null;
30
+ _length: number | undefined;
31
+ _area: number | undefined;
32
+ _strokeProfile: StrokeProfile | null;
33
+ _strokeOutline: PathItem | undefined;
34
+ /**
35
+ * Creates a new path item and places it at the top of the active layer.
36
+ *
37
+ * @param segments An array of segments (or points to be converted to
38
+ * segments) that will be added to the path
39
+ *
40
+ * @example
41
+ * // Create an empty path and add segments to it:
42
+ * var path = new Path();
43
+ * path.strokeColor = 'black';
44
+ * path.add(new Point(30, 30));
45
+ * path.add(new Point(100, 100));
46
+ *
47
+ * @example
48
+ * // Create a path with two segments:
49
+ * var segments = [new Point(30, 30), new Point(100, 100)];
50
+ * var path = new Path(segments);
51
+ * path.strokeColor = 'black';
52
+ */
53
+ constructor(segments?: SegmentLike[]);
54
+ /**
55
+ * Creates a new path item from an object description and places it at the
56
+ * top of the active layer.
57
+ *
58
+ * @param object an object containing properties to be set on the
59
+ * path
60
+ *
61
+ * @example {@paperscript}
62
+ * var path = new Path({
63
+ * segments: [[20, 20], [80, 80], [140, 20]],
64
+ * fillColor: 'black',
65
+ * closed: true
66
+ * });
67
+ *
68
+ * @example {@paperscript}
69
+ * var path = new Path({
70
+ * segments: [[20, 20], [80, 80], [140, 20]],
71
+ * strokeColor: 'red',
72
+ * strokeWidth: 20,
73
+ * strokeCap: 'round',
74
+ * selected: true
75
+ * });
76
+ */
77
+ constructor(object: ItemProps<Path>);
78
+ /**
79
+ * Creates a new path item from SVG path-data and places it at the top of
80
+ * the active layer. A path holds a single sub-path: further `M` commands
81
+ * are ignored, and the commands that follow them continue the same path.
82
+ * Use {@link CompoundPath} or {@link PathItem.create(pathData)} to create
83
+ * items with multiple sub-paths.
84
+ *
85
+ * @param pathData the SVG path-data that describes the geometry
86
+ * of this path
87
+ *
88
+ * @example {@paperscript}
89
+ * var pathData = 'M100,50c0,27.614-22.386,50-50,50S0,77.614,0,50S22.386,0,50,0S100,22.386,100,50';
90
+ * var path = new Path(pathData);
91
+ * path.fillColor = 'red';
92
+ */
93
+ constructor(pathData: string);
94
+ constructor(...segments: SegmentLike[]);
95
+ /**
96
+ * {@grouptitle Shaped Paths}
97
+ *
98
+ * Creates a linear path item from two points describing a line.
99
+ *
100
+ * @param from the line's starting point
101
+ * @param to the line's ending point
102
+ * @return the newly created path
103
+ *
104
+ * @example {@paperscript}
105
+ * var from = new Point(20, 20);
106
+ * var to = new Point(80, 80);
107
+ * var path = Path.line(from, to);
108
+ * path.strokeColor = 'black';
109
+ */
110
+ static line(from: PointLike, to: PointLike): Path;
111
+ /**
112
+ * Creates a linear path item from the properties described by an object
113
+ * literal.
114
+ *
115
+ * @param object an object containing properties describing the path's
116
+ * attributes
117
+ * @return the newly created path
118
+ *
119
+ * @example {@paperscript}
120
+ * var path = Path.line({
121
+ * from: [20, 20],
122
+ * to: [80, 80],
123
+ * strokeColor: 'black'
124
+ * });
125
+ */
126
+ static line(object: {
127
+ from: PointLike;
128
+ to: PointLike;
129
+ } & PathProps): Path;
130
+ /**
131
+ * Creates a circular path item.
132
+ *
133
+ * @param center the center point of the circle
134
+ * @param radius the radius of the circle
135
+ * @return the newly created path
136
+ *
137
+ * @example {@paperscript}
138
+ * var path = Path.circle(new Point(80, 50), 30);
139
+ * path.strokeColor = 'black';
140
+ */
141
+ static circle(center: PointLike, radius: number): Path;
142
+ /**
143
+ * Creates a circular path item from the properties described by an object
144
+ * literal.
145
+ *
146
+ * @param object an object containing properties describing the path's
147
+ * attributes
148
+ * @return the newly created path
149
+ *
150
+ * @example {@paperscript}
151
+ * var path = Path.circle({
152
+ * center: [80, 50],
153
+ * radius: 30,
154
+ * strokeColor: 'black'
155
+ * });
156
+ */
157
+ static circle(object: {
158
+ center: PointLike;
159
+ radius: number;
160
+ } & PathProps): Path;
161
+ /**
162
+ * Creates a rectangular path item, with optionally rounded corners.
163
+ *
164
+ * @param rectangle the rectangle object describing the geometry of the
165
+ * rectangular path to be created
166
+ * @param [radius=null] the size of the rounded corners
167
+ * @return the newly created path
168
+ *
169
+ * @example {@paperscript}
170
+ * var rectangle = new Rectangle(new Point(20, 20), new Size(60, 60));
171
+ * var path = Path.rectangle(rectangle);
172
+ * path.strokeColor = 'black';
173
+ *
174
+ * @example {@paperscript} // The same, with rounder corners
175
+ * var rectangle = new Rectangle(new Point(20, 20), new Size(60, 60));
176
+ * var cornerSize = new Size(10, 10);
177
+ * var path = Path.rectangle(rectangle, cornerSize);
178
+ * path.strokeColor = 'black';
179
+ */
180
+ static rectangle(rectangle: RectangleLike, radius?: SizeLike | number): Path;
181
+ /**
182
+ * Creates a rectangular path item from a point and a size object.
183
+ *
184
+ * @param point the rectangle's top-left corner.
185
+ * @param size the rectangle's size.
186
+ * @return the newly created path
187
+ *
188
+ * @example {@paperscript}
189
+ * var point = new Point(20, 20);
190
+ * var size = new Size(60, 60);
191
+ * var path = Path.rectangle(point, size);
192
+ * path.strokeColor = 'black';
193
+ */
194
+ static rectangle(point: PointLike, size: SizeLike): Path;
195
+ /**
196
+ * Creates a rectangular path item from the passed points. These do not
197
+ * necessarily need to be the top left and bottom right corners, the
198
+ * factory figures out how to fit a rectangle between them.
199
+ *
200
+ * @param from the first point defining the rectangle
201
+ * @param to the second point defining the rectangle
202
+ * @return the newly created path
203
+ *
204
+ * @example {@paperscript}
205
+ * var from = new Point(20, 20);
206
+ * var to = new Point(80, 80);
207
+ * var path = Path.rectangle(from, to);
208
+ * path.strokeColor = 'black';
209
+ */
210
+ static rectangle(from: PointLike, to: PointLike): Path;
211
+ /**
212
+ * Creates a rectangular path item from the properties described by an
213
+ * object literal.
214
+ *
215
+ * @param object an object containing properties describing the path's
216
+ * attributes
217
+ * @return the newly created path
218
+ *
219
+ * @example {@paperscript}
220
+ * var path = Path.rectangle({
221
+ * point: [20, 20],
222
+ * size: [60, 60],
223
+ * strokeColor: 'black'
224
+ * });
225
+ *
226
+ * @example {@paperscript}
227
+ * var path = Path.rectangle({
228
+ * from: [20, 20],
229
+ * to: [80, 80],
230
+ * strokeColor: 'black'
231
+ * });
232
+ *
233
+ * @example {@paperscript}
234
+ * var path = Path.rectangle({
235
+ * rectangle: {
236
+ * topLeft: [20, 20],
237
+ * bottomRight: [80, 80]
238
+ * },
239
+ * strokeColor: 'black'
240
+ * });
241
+ *
242
+ * @example {@paperscript}
243
+ * var path = Path.rectangle({
244
+ * topLeft: [20, 20],
245
+ * bottomRight: [80, 80],
246
+ * radius: 10,
247
+ * strokeColor: 'black'
248
+ * });
249
+ */
250
+ static rectangle(object: RectangleProps & PathProps): Path;
251
+ /**
252
+ * Creates an elliptical path item.
253
+ *
254
+ * @param rectangle the rectangle circumscribing the ellipse
255
+ * @return the newly created path
256
+ *
257
+ * @example {@paperscript}
258
+ * var rectangle = new Rectangle(new Point(20, 20), new Size(180, 60));
259
+ * var path = Path.ellipse(rectangle);
260
+ * path.fillColor = 'black';
261
+ */
262
+ static ellipse(rectangle: RectangleLike): Path;
263
+ /**
264
+ * Creates an elliptical path item from the properties described by an
265
+ * object literal.
266
+ *
267
+ * @param object an object containing properties describing the path's
268
+ * attributes
269
+ * @return the newly created path
270
+ *
271
+ * @example {@paperscript}
272
+ * var path = Path.ellipse({
273
+ * point: [20, 20],
274
+ * size: [180, 60],
275
+ * fillColor: 'black'
276
+ * });
277
+ *
278
+ * @example {@paperscript} // Placing by center and radius
279
+ * var shape = Path.ellipse({
280
+ * center: [110, 50],
281
+ * radius: [90, 30],
282
+ * fillColor: 'black'
283
+ * });
284
+ */
285
+ static ellipse(object: RectangleProps & PathProps): Path;
286
+ /**
287
+ * Creates a circular arc path item.
288
+ *
289
+ * @param from the starting point of the circular arc
290
+ * @param through the point the arc passes through
291
+ * @param to the end point of the arc
292
+ * @return the newly created path
293
+ *
294
+ * @example {@paperscript}
295
+ * var from = new Point(20, 20);
296
+ * var through = new Point(60, 20);
297
+ * var to = new Point(80, 80);
298
+ * var path = Path.arc(from, through, to);
299
+ * path.strokeColor = 'black';
300
+ */
301
+ static arc(from: PointLike, through: PointLike, to: PointLike): Path;
302
+ /**
303
+ * Creates a circular arc path item from the properties described by an
304
+ * object literal.
305
+ *
306
+ * @param object an object containing properties describing the path's
307
+ * attributes
308
+ * @return the newly created path
309
+ *
310
+ * @example {@paperscript}
311
+ * var path = Path.arc({
312
+ * from: [20, 20],
313
+ * through: [60, 20],
314
+ * to: [80, 80],
315
+ * strokeColor: 'black'
316
+ * });
317
+ */
318
+ static arc(object: {
319
+ from: PointLike;
320
+ through: PointLike;
321
+ to: PointLike;
322
+ } & PathProps): Path;
323
+ /**
324
+ * Creates a regular polygon shaped path item. As in Illustrator, it stands
325
+ * on a flat bottom edge, and its segments run counterclockwise from its top
326
+ * vertex, or with an even number of sides, from the right end of its top
327
+ * edge.
328
+ *
329
+ * @param center the center point of the polygon
330
+ * @param sides the number of sides of the polygon
331
+ * @param radius the radius of the polygon
332
+ * @return the newly created path
333
+ *
334
+ * @example {@paperscript}
335
+ * var center = new Point(50, 50);
336
+ * var sides = 3;
337
+ * var radius = 40;
338
+ * var triangle = Path.regularPolygon(center, sides, radius);
339
+ * triangle.fillColor = 'black';
340
+ */
341
+ static regularPolygon(center: PointLike, sides: number, radius: number): Path;
342
+ /**
343
+ * Creates a regular polygon shaped path item from the properties described
344
+ * by an object literal.
345
+ *
346
+ * @param object an object containing properties describing the path's
347
+ * attributes
348
+ * @return the newly created path
349
+ *
350
+ * @example {@paperscript}
351
+ * var triangle = Path.regularPolygon({
352
+ * center: [50, 50],
353
+ * sides: 10,
354
+ * radius: 40,
355
+ * fillColor: 'black'
356
+ * });
357
+ */
358
+ static regularPolygon(object: {
359
+ center: PointLike;
360
+ sides: number;
361
+ radius: number;
362
+ } & PathProps): Path;
363
+ /**
364
+ * Creates a star shaped path item.
365
+ *
366
+ * The largest of `radius1` and `radius2` will be the outer radius of the
367
+ * star. The smallest of radius1 and radius2 will be the inner radius.
368
+ *
369
+ * @param center the center point of the star
370
+ * @param points the number of points of the star
371
+ * @param radius1
372
+ * @param radius2
373
+ * @return the newly created path
374
+ *
375
+ * @example {@paperscript}
376
+ * var center = new Point(50, 50);
377
+ * var points = 12;
378
+ * var radius1 = 25;
379
+ * var radius2 = 40;
380
+ * var path = Path.star(center, points, radius1, radius2);
381
+ * path.fillColor = 'black';
382
+ */
383
+ static star(center: PointLike, points: number, radius1: number, radius2: number): Path;
384
+ /**
385
+ * Creates a star shaped path item from the properties described by an
386
+ * object literal.
387
+ *
388
+ * @param object an object containing properties describing the path's
389
+ * attributes
390
+ * @return the newly created path
391
+ *
392
+ * @example {@paperscript}
393
+ * var path = Path.star({
394
+ * center: [50, 50],
395
+ * points: 12,
396
+ * radius1: 25,
397
+ * radius2: 40,
398
+ * fillColor: 'black'
399
+ * });
400
+ */
401
+ static star(object: {
402
+ center: PointLike;
403
+ points: number;
404
+ radius1: number;
405
+ radius2: number;
406
+ } & PathProps): Path;
407
+ _initializeContent(project: Project): void;
408
+ _equals(item: this): boolean;
409
+ copyContent(source: this): void;
410
+ _changed(flags: number): void;
411
+ _getPaths(): Path[];
412
+ _hasStrokeProfile(): boolean;
413
+ get style(): Style;
414
+ set style(style: Style | object);
415
+ /**
416
+ * The segments contained within the path. Segments that define a
417
+ * {@link Segment#name} can also be accessed by name.
418
+ *
419
+ * @example {@paperscript}
420
+ * // Accessing segments by name:
421
+ * var path = new Path([20, 80], [50, 20], [80, 80]);
422
+ * path.strokeColor = 'black';
423
+ *
424
+ * // Set the name of the top segment:
425
+ * path.segments[1].name = 'top';
426
+ *
427
+ * // The segment can be accessed by name:
428
+ * path.segments['top'].point.y += 20;
429
+ */
430
+ get segments(): Segment[];
431
+ set segments(segments: SegmentLike[]);
432
+ /**
433
+ * The first Segment contained within the path.
434
+ */
435
+ get firstSegment(): Segment;
436
+ /**
437
+ * The last Segment contained within the path.
438
+ */
439
+ get lastSegment(): Segment;
440
+ /**
441
+ * The curves contained within the path.
442
+ */
443
+ get curves(): Curve[];
444
+ /**
445
+ * The first Curve contained within the path.
446
+ */
447
+ get firstCurve(): Curve;
448
+ /**
449
+ * The last Curve contained within the path.
450
+ */
451
+ get lastCurve(): Curve;
452
+ /**
453
+ * Specifies whether the path is closed. If it is closed, Paper.js connects
454
+ * the first and last segments.
455
+ *
456
+ * @example {@paperscript}
457
+ * var myPath = new Path();
458
+ * myPath.strokeColor = 'black';
459
+ * myPath.add(new Point(50, 75));
460
+ * myPath.add(new Point(100, 25));
461
+ * myPath.add(new Point(150, 75));
462
+ *
463
+ * // Close the path:
464
+ * myPath.closed = true;
465
+ */
466
+ get closed(): boolean;
467
+ set closed(closed: boolean);
468
+ isEmpty(): boolean;
469
+ _transformContent(matrix: Matrix, options?: TransformOptions): boolean;
470
+ /**
471
+ * Private method that adds segments to the segment list. It assumes that
472
+ * the passed object is an array of segments already and does not perform
473
+ * any checks. If a curves list was requested, it will be kept in sync with
474
+ * the segments list automatically.
475
+ */
476
+ _add(segs: Segment[] & {
477
+ _curves?: Curve[];
478
+ }, index?: number): Segment[];
479
+ /**
480
+ * Adjusts segments of curves before and after inserted / removed segments.
481
+ */
482
+ _adjustCurves(start: number, end: number): void;
483
+ /**
484
+ * Returns the amount of curves this path item is supposed to have, based
485
+ * on its amount of #segments and #closed state.
486
+ */
487
+ _countCurves(): number;
488
+ /**
489
+ * Adds a segment to the end of the {@link #segments} array of this path.
490
+ *
491
+ * @param segment the segment or point to be added
492
+ * @return the added segment. This is not necessarily the same object, e.g.
493
+ * if the segment to be added already belongs to another path.
494
+ */
495
+ add(segment: SegmentLike): Segment;
496
+ /**
497
+ * Adds one or more segments to the end of the {@link #segments} array of
498
+ * this path.
499
+ *
500
+ * @param segments the segments or points to be added, each as a separate
501
+ * argument
502
+ * @return the added segments. These are not necessarily the same
503
+ * objects, e.g. if a segment to be added already belongs to another
504
+ * path.
505
+ *
506
+ * @example {@paperscript}
507
+ * // Adding segments to a path using point objects:
508
+ * var path = new Path({
509
+ * strokeColor: 'black'
510
+ * });
511
+ *
512
+ * // Add a segment at {x: 30, y: 75}
513
+ * path.add(new Point(30, 75));
514
+ *
515
+ * // Add two segments in one go at {x: 100, y: 20}
516
+ * // and {x: 170, y: 75}:
517
+ * path.add(new Point(100, 20), new Point(170, 75));
518
+ *
519
+ * @example {@paperscript}
520
+ * // Adding segments to a path using arrays containing number pairs:
521
+ * var path = new Path({
522
+ * strokeColor: 'black'
523
+ * });
524
+ *
525
+ * // Add a segment at {x: 30, y: 75}
526
+ * path.add([30, 75]);
527
+ *
528
+ * // Add two segments in one go at {x: 100, y: 20}
529
+ * // and {x: 170, y: 75}:
530
+ * path.add([100, 20], [170, 75]);
531
+ *
532
+ * @example {@paperscript}
533
+ * // Adding segments to a path using objects:
534
+ * var path = new Path({
535
+ * strokeColor: 'black'
536
+ * });
537
+ *
538
+ * // Add a segment at {x: 30, y: 75}
539
+ * path.add({x: 30, y: 75});
540
+ *
541
+ * // Add two segments in one go at {x: 100, y: 20}
542
+ * // and {x: 170, y: 75}:
543
+ * path.add({x: 100, y: 20}, {x: 170, y: 75});
544
+ *
545
+ * @example {@paperscript}
546
+ * // Adding a segment with handles to a path:
547
+ * var path = new Path({
548
+ * strokeColor: 'black'
549
+ * });
550
+ *
551
+ * path.add(new Point(30, 75));
552
+ *
553
+ * // Add a segment with handles:
554
+ * var point = new Point(100, 20);
555
+ * var handleIn = new Point(-50, 0);
556
+ * var handleOut = new Point(50, 0);
557
+ * var added = path.add(new Segment(point, handleIn, handleOut));
558
+ *
559
+ * // Select the added segment, so we can see its handles:
560
+ * added.selected = true;
561
+ *
562
+ * path.add(new Point(170, 75));
563
+ */
564
+ add(...segments: SegmentLike[]): Segment[];
565
+ /**
566
+ * Inserts one or more segments at a given index in the list of this path's
567
+ * segments.
568
+ *
569
+ * @param index the index at which to insert the segment
570
+ * @param segment the segment or point to be inserted.
571
+ * @return the added segment. This is not necessarily the same
572
+ * object, e.g. if the segment to be added already belongs to another path
573
+ *
574
+ * @example {@paperscript}
575
+ * // Inserting a segment:
576
+ * var myPath = new Path();
577
+ * myPath.strokeColor = 'black';
578
+ * myPath.add(new Point(50, 75));
579
+ * myPath.add(new Point(150, 75));
580
+ *
581
+ * // Insert a new segment into myPath at index 1:
582
+ * myPath.insert(1, new Point(100, 25));
583
+ *
584
+ * // Select the segment which we just inserted:
585
+ * myPath.segments[1].selected = true;
586
+ *
587
+ * @example {@paperscript}
588
+ * // Inserting multiple segments:
589
+ * var myPath = new Path();
590
+ * myPath.strokeColor = 'black';
591
+ * myPath.add(new Point(50, 75));
592
+ * myPath.add(new Point(150, 75));
593
+ *
594
+ * // Insert two segments into myPath at index 1:
595
+ * myPath.insert(1, [80, 25], [120, 25]);
596
+ *
597
+ * // Select the segments which we just inserted:
598
+ * myPath.segments[1].selected = true;
599
+ * myPath.segments[2].selected = true;
600
+ */
601
+ insert(index: number, segment: SegmentLike): Segment;
602
+ insert(index: number, ...segments: SegmentLike[]): Segment[];
603
+ addSegment(segment: SegmentLike): Segment;
604
+ insertSegment(index: number, segment: SegmentLike): Segment;
605
+ /**
606
+ * Adds an array of segments (or types that can be converted to segments)
607
+ * to the end of the {@link #segments} array.
608
+ *
609
+ * @param segments the segments to be added
610
+ * @return an array of the added segments. These segments are
611
+ * not necessarily the same objects, e.g. if the segment to be added already
612
+ * belongs to another path
613
+ *
614
+ * @example {@paperscript}
615
+ * // Adding an array of Point objects:
616
+ * var path = new Path({
617
+ * strokeColor: 'black'
618
+ * });
619
+ * var points = [new Point(30, 50), new Point(170, 50)];
620
+ * path.addSegments(points);
621
+ *
622
+ * @example {@paperscript}
623
+ * // Adding an array of [x, y] arrays:
624
+ * var path = new Path({
625
+ * strokeColor: 'black'
626
+ * });
627
+ * var array = [[30, 75], [100, 20], [170, 75]];
628
+ * path.addSegments(array);
629
+ *
630
+ * @example {@paperscript}
631
+ * // Adding segments from one path to another:
632
+ *
633
+ * var path = new Path({
634
+ * strokeColor: 'black'
635
+ * });
636
+ * path.addSegments([[30, 75], [100, 20], [170, 75]]);
637
+ *
638
+ * var path2 = new Path();
639
+ * path2.strokeColor = 'red';
640
+ *
641
+ * // Add the second and third segments of path to path2:
642
+ * path2.add(path.segments[1], path.segments[2]);
643
+ *
644
+ * // Move path2 30pt to the right:
645
+ * path2.position.x += 30;
646
+ */
647
+ addSegments(segments: SegmentLike[]): Segment[];
648
+ /**
649
+ * Inserts an array of segments at a given index in the path's
650
+ * {@link #segments} array.
651
+ *
652
+ * @param index the index at which to insert the segments
653
+ * @param segments the segments to be inserted
654
+ * @return an array of the added segments. These segments are
655
+ * not necessarily the same objects, e.g. if the segment to be added already
656
+ * belongs to another path
657
+ */
658
+ insertSegments(index: number, segments: SegmentLike[]): Segment[];
659
+ /**
660
+ * Removes the segment at the specified index of the path's
661
+ * {@link #segments} array.
662
+ *
663
+ * @param index the index of the segment to be removed
664
+ * @return the removed segment
665
+ *
666
+ * @example {@paperscript}
667
+ * // Removing a segment from a path:
668
+ *
669
+ * // Create a circle shaped path at { x: 80, y: 50 }
670
+ * // with a radius of 35:
671
+ * var path = Path.circle({
672
+ * center: new Point(80, 50),
673
+ * radius: 35,
674
+ * strokeColor: 'black'
675
+ * });
676
+ *
677
+ * // Remove its second segment:
678
+ * path.removeSegment(1);
679
+ *
680
+ * // Select the path, so we can see its segments:
681
+ * path.selected = true;
682
+ */
683
+ removeSegment(index: number): Segment | null;
684
+ /**
685
+ * Removes all segments from the path's {@link #segments} array.
686
+ *
687
+ * @return an array containing the removed segments
688
+ */
689
+ removeSegments(): Segment[];
690
+ /**
691
+ * Removes the segments from the specified `from` index to the `to` index
692
+ * from the path's {@link #segments} array. On closed paths, `from` can be
693
+ * bigger than `to`, to remove the segments from `from` to the end and then
694
+ * from the beginning up to `to`, wrapping around the closing curve.
695
+ *
696
+ * @param from the beginning index, inclusive
697
+ * @param [to=segments.length] the ending index, exclusive
698
+ * @return an array containing the removed segments, in the
699
+ * order in which they appeared along the path
700
+ *
701
+ * @example {@paperscript}
702
+ * // Removing segments from a path:
703
+ *
704
+ * // Create a circle shaped path at { x: 80, y: 50 }
705
+ * // with a radius of 35:
706
+ * var path = Path.circle({
707
+ * center: new Point(80, 50),
708
+ * radius: 35,
709
+ * strokeColor: 'black'
710
+ * });
711
+ *
712
+ * // Remove the segments from index 1 till index 2:
713
+ * path.removeSegments(1, 2);
714
+ *
715
+ * // Select the path, so we can see its segments:
716
+ * path.selected = true;
717
+ */
718
+ removeSegments(from: number, to?: number): Segment[];
719
+ /**
720
+ * Removes all segments of the path, as {@link #removeSegments()} does.
721
+ *
722
+ * @return the removed segments
723
+ */
724
+ clear(): Segment[];
725
+ /**
726
+ * Checks if any of the curves in the path have curve handles set. Handles
727
+ * of which both coordinates are 0 within a tolerance of 1e-12 count as not
728
+ * set, see {@link Point#isZero()}.
729
+ *
730
+ * @return {@true if the path has curve handles set}
731
+ * @see Segment#hasHandles()
732
+ * @see Curve#hasHandles()
733
+ */
734
+ hasHandles(): boolean;
735
+ /**
736
+ * Clears the path's handles by setting their coordinates to zero,
737
+ * turning the path into a polygon (or a polyline if it isn't closed).
738
+ */
739
+ clearHandles(): void;
740
+ /**
741
+ * The approximate length of the path.
742
+ */
743
+ get length(): number;
744
+ /**
745
+ * The area that the path's geometry is covering. Self-intersecting paths
746
+ * can contain sub-areas that cancel each other out.
747
+ */
748
+ get area(): number;
749
+ /**
750
+ * Specifies whether the path and all its segments are selected. Cannot be
751
+ * `true` on an empty path.
752
+ *
753
+ * @example {@paperscript}
754
+ * // A path is fully selected, if all of its segments are selected:
755
+ * var path = Path.circle({
756
+ * center: [80, 50],
757
+ * radius: 35
758
+ * });
759
+ * path.fullySelected = true;
760
+ *
761
+ * var path2 = Path.circle({
762
+ * center: [180, 50],
763
+ * radius: 35
764
+ * });
765
+ *
766
+ * // Deselect the second segment of the second path:
767
+ * path2.segments[1].selected = false;
768
+ *
769
+ * // If the path is fully selected (which it is),
770
+ * // set its fill color to red:
771
+ * if (path.fullySelected) {
772
+ * path.fillColor = 'red';
773
+ * }
774
+ *
775
+ * // If the second path is fully selected (which it isn't, since we just
776
+ * // deselected its second segment),
777
+ * // set its fill color to red:
778
+ * if (path2.fullySelected) {
779
+ * path2.fillColor = 'red';
780
+ * }
781
+ */
782
+ get fullySelected(): boolean;
783
+ set fullySelected(selected: boolean);
784
+ get selection(): number;
785
+ set selection(selection: number);
786
+ _selectSegments(selected: boolean): void;
787
+ _updateSelection(segment: Segment, oldSelection: number, newSelection: number): void;
788
+ /**
789
+ * Divides the path on the curve at the given offset or location into two
790
+ * curves, by inserting a new segment at the given location.
791
+ *
792
+ * @param location the offset or location on the
793
+ * path at which to divide the existing curve by inserting a new segment
794
+ * @return the newly inserted segment if the location is valid,
795
+ * `null` otherwise
796
+ * @see Curve#divideAt(location)
797
+ */
798
+ divideAt(location: number | CurveLocation): Segment | null;
799
+ /**
800
+ * Splits the path at the given offset or location. After splitting, the
801
+ * path will be open. If the path was open already, splitting will result in
802
+ * two paths.
803
+ *
804
+ * @param location the offset or location at which to
805
+ * split the path
806
+ * @return the newly created path after splitting, if any
807
+ *
808
+ * @example {@paperscript}
809
+ * var path = Path.circle({
810
+ * center: view.center,
811
+ * radius: 40,
812
+ * strokeColor: 'black'
813
+ * });
814
+ *
815
+ * var pointOnCircle = view.center + {
816
+ * length: 40,
817
+ * angle: 30
818
+ * };
819
+ *
820
+ * var location = path.getNearestLocation(pointOnCircle);
821
+ *
822
+ * path.splitAt(location);
823
+ * path.lastSegment.selected = true;
824
+ *
825
+ * @example {@paperscript} // Splitting an open path
826
+ * // Draw a V shaped path:
827
+ * var path = new Path([20, 20], [50, 80], [80, 20]);
828
+ * path.strokeColor = 'black';
829
+ *
830
+ * // Split the path half-way:
831
+ * var path2 = path.splitAt(path.length / 2);
832
+ *
833
+ * // Give the resulting path a red stroke-color
834
+ * // and move it 20px to the right:
835
+ * path2.strokeColor = 'red';
836
+ * path2.position.x += 20;
837
+ *
838
+ * @example {@paperscript} // Splitting a closed path
839
+ * var path = Path.rectangle({
840
+ * from: [20, 20],
841
+ * to: [80, 80],
842
+ * strokeColor: 'black'
843
+ * });
844
+ *
845
+ * // Split the path half-way:
846
+ * path.splitAt(path.length / 2);
847
+ *
848
+ * // Move the first segment, to show where the path
849
+ * // was split:
850
+ * path.firstSegment.point.x += 20;
851
+ *
852
+ * // Select the first segment:
853
+ * path.firstSegment.selected = true;
854
+ */
855
+ splitAt(location: number | CurveLocation): Path | null;
856
+ /**
857
+ * Joins the path with the other specified path, which will be removed in
858
+ * the process. They can be joined if the first or last segments of either
859
+ * path lie in the same location. Locations are optionally compared with a
860
+ * provided `tolerance` value.
861
+ *
862
+ * If `null` or `this` is passed as the other path, the path will be joined
863
+ * with itself if the first and last segment are in the same location.
864
+ *
865
+ * @param path the path to join this path with; `null` or `this` to
866
+ * join the path with itself
867
+ * @param [tolerance=0] the tolerance with which to decide if two
868
+ * segments are to be considered the same location when joining
869
+ *
870
+ * @example {@paperscript}
871
+ * // Joining two paths:
872
+ * var path = new Path({
873
+ * segments: [[30, 25], [30, 75]],
874
+ * strokeColor: 'black'
875
+ * });
876
+ *
877
+ * var path2 = new Path({
878
+ * segments: [[200, 25], [200, 75]],
879
+ * strokeColor: 'black'
880
+ * });
881
+ *
882
+ * // Join the paths:
883
+ * path.join(path2);
884
+ *
885
+ * @example {@paperscript}
886
+ * // Joining two paths that share a point at the start or end of their
887
+ * // segments array:
888
+ * var path = new Path({
889
+ * segments: [[30, 25], [30, 75]],
890
+ * strokeColor: 'black'
891
+ * });
892
+ *
893
+ * var path2 = new Path({
894
+ * segments: [[30, 25], [80, 25]],
895
+ * strokeColor: 'black'
896
+ * });
897
+ *
898
+ * // Join the paths:
899
+ * path.join(path2);
900
+ *
901
+ * // After joining, path with have 3 segments, since it
902
+ * // shared its first segment point with the first
903
+ * // segment point of path2.
904
+ *
905
+ * // Select the path to show that they have joined:
906
+ * path.selected = true;
907
+ *
908
+ * @example {@paperscript}
909
+ * // Joining two paths that connect at two points:
910
+ * var path = new Path({
911
+ * segments: [[30, 25], [80, 25], [80, 75]],
912
+ * strokeColor: 'black'
913
+ * });
914
+ *
915
+ * var path2 = new Path({
916
+ * segments: [[30, 25], [30, 75], [80, 75]],
917
+ * strokeColor: 'black'
918
+ * });
919
+ *
920
+ * // Join the paths:
921
+ * path.join(path2);
922
+ *
923
+ * // Because the paths were joined at two points, the path is closed
924
+ * // and has 4 segments.
925
+ *
926
+ * // Select the path to show that they have joined:
927
+ * path.selected = true;
928
+ */
929
+ join(path: Path | null, tolerance?: number): this;
930
+ /**
931
+ * Reduces the path by removing straight curves that have a length of 0.
932
+ * With `options.simplify`, it also removes straight curves that are almost
933
+ * 0 in length, and unnecessary segments between two collinear straight
934
+ * curves.
935
+ *
936
+ * @option [options.simplify=false] {Boolean} also remove almost zero-length
937
+ * curves and segments between collinear straight curves
938
+ *
939
+ * @param options the reduce options
940
+ * @return the reduced path
941
+ */
942
+ reduce(options?: {
943
+ simplify?: boolean;
944
+ }): this;
945
+ reverse(): this;
946
+ flatten(flatness?: number): this;
947
+ simplify(options?: PathSimplifyOptions | number): boolean;
948
+ smooth(options?: PathSmoothOptions): this;
949
+ /**
950
+ * Attempts to create a new shape item with same geometry as this path item,
951
+ * and inherits all settings from it, similar to {@link Item#clone()}.
952
+ *
953
+ * @param [insert=true] specifies whether the new shape should be
954
+ * inserted into the scene graph. When set to `true`, it is inserted above
955
+ * the path item
956
+ * @return the newly created shape item with the same geometry as
957
+ * this path item if it can be matched, `null` otherwise
958
+ * @see Shape#toPath(insert)
959
+ */
960
+ toShape(insert?: boolean): Shape | null;
961
+ toPath(insert?: boolean): Path;
962
+ compare(path: PathItem): boolean;
963
+ _hitTestSelf(point: Point, options: HitTestOptions, viewMatrix: Matrix | null | undefined, strokeMatrix: Matrix | null | undefined): HitResult | HitResult[] | null;
964
+ /**
965
+ * {@grouptitle Positions on Paths and Curves}
966
+ *
967
+ * Returns the curve location of the specified point if it lies on the
968
+ * path, `null` otherwise.
969
+ *
970
+ * @param point the point on the path
971
+ * @return the curve location of the specified point
972
+ */
973
+ getLocationOf(point: PointLike | number, y?: number): CurveLocation | null;
974
+ /**
975
+ * Returns the length of the path from its beginning up to the
976
+ * specified point if it lies on the path, `null` otherwise.
977
+ *
978
+ * @param point the point on the path
979
+ * @return the length of the path up to the specified point
980
+ */
981
+ getOffsetOf(point: PointLike | number, y?: number): number | null;
982
+ /**
983
+ * Returns the curve location of the specified offset on the path, or
984
+ * `null` if the offset exceeds the length of the path.
985
+ *
986
+ * @param offset the offset on the path, where `0` is at
987
+ * the beginning of the path and {@link Path#length} at the end
988
+ * @return the curve location at the specified offset
989
+ */
990
+ getLocationAt(offset: number | CurveLocation): CurveLocation | null;
991
+ /**
992
+ * Calculates path offsets where the path is tangential to the provided
993
+ * tangent. Note that tangents at the start or end are included. Tangents at
994
+ * segment points are returned even if only one of their handles is
995
+ * collinear with the provided tangent.
996
+ *
997
+ * @param tangent the tangent to which the path must be tangential
998
+ * @return path offsets where the path is tangential to the
999
+ * provided tangent
1000
+ */
1001
+ getOffsetsWithTangent(tangent: PointLike | number, y?: number): number[];
1002
+ _draw(ctx: CanvasRenderingContext2D, param: DrawParam, viewMatrix: Matrix, strokeMatrix: Matrix | null | undefined): void;
1003
+ _drawGeometry(ctx: CanvasRenderingContext2D, matrix: Matrix | null): void;
1004
+ _drawSelected(ctx: CanvasRenderingContext2D, matrix: Matrix): void;
1005
+ moveTo(point: PointLike | number, y?: number): this;
1006
+ moveBy(): never;
1007
+ lineTo(point: PointLike | number, y?: number): this;
1008
+ cubicCurveTo(handle1: PointLike, handle2: PointLike, to: PointLike): this;
1009
+ cubicCurveTo(...coordinates: CubicCoordinates): this;
1010
+ quadraticCurveTo(handle: PointLike, to: PointLike): this;
1011
+ quadraticCurveTo(...coordinates: QuadraticCoordinates): this;
1012
+ curveTo(through: PointLike, to: PointLike, time?: number): this;
1013
+ arcTo(to: PointLike, arg?: boolean | PointLike | SizeLike | number, rotation?: number, clockwise?: boolean | number, large?: boolean | number): this;
1014
+ arcAround(center: PointLike, angle: number): this;
1015
+ arcTowards(point: PointLike | number, y?: number): this;
1016
+ lineBy(point: PointLike | number, y?: number): this;
1017
+ curveBy(through: PointLike, to: PointLike, time?: number): this;
1018
+ cubicCurveBy(handle1: PointLike, handle2: PointLike, to: PointLike): this;
1019
+ cubicCurveBy(...coordinates: CubicCoordinates): this;
1020
+ quadraticCurveBy(handle: PointLike, to: PointLike): this;
1021
+ quadraticCurveBy(...coordinates: QuadraticCoordinates): this;
1022
+ arcBy(point: PointLike, arg?: boolean | PointLike): this;
1023
+ closePath(tolerance?: number): this;
1024
+ _getBounds(matrix: Matrix | null, options: BoundsOptions): Rectangle;
1025
+ _getStrokeOutline(): PathItem;
1026
+ /**
1027
+ * {@grouptitle Stroke Profile}
1028
+ *
1029
+ * The stroke profile of the path: the stops along it that set the pen
1030
+ * that draws its stroke, an ellipse with a width, as a factor of its
1031
+ * {@link Style#strokeWidth}, an aspect and an angle, see
1032
+ * {@link StrokeProfileStop}. The stops are sorted by their offsets.
1033
+ * Between the stops that set a value, it changes along the path,
1034
+ * easing into and out of smooth stops and in straight lines from the
1035
+ * others, see {@link StrokeProfileStop#smooth}, and beyond the ends
1036
+ * of open paths, it stays as at the first and last of them. Two stops
1037
+ * at the same offset make a step. The stops stay between the same
1038
+ * segments when they move. Without a stroke profile, the stroke is
1039
+ * drawn with a round pen of the stroke width all along.
1040
+ *
1041
+ * It is a property of the path, not of its style, as it is tied to
1042
+ * its segments. It can be set to stops or plain objects describing
1043
+ * them, `{ offset, width, aspect, angle, smooth }`, and JSON stores
1044
+ * them with the indices that tie them to the segments instead of
1045
+ * their offsets, `{ index, width, aspect, angle, smooth }`. Changing
1046
+ * the returned array directly isn't tracked, as with
1047
+ * {@link #segments}.
1048
+ *
1049
+ * The path draws its stroke as the area that the pens sweep, filled
1050
+ * with the stroke color, as {@link PathItem#outline()} returns it,
1051
+ * and {@link Item#strokeBounds} and hit-testing measure that area.
1052
+ * The children of compound paths are drawn with the stroke of their
1053
+ * parent, each with its own profile. With {@link Style#strokeScaling}
1054
+ * off, the profile scales with the view. The boolean operations and
1055
+ * {@link PathItem#resolveCrossings()} return paths with the profile
1056
+ * of each path that they run along, with a step where two of them
1057
+ * meet, and {@link PathItem#offset()} carries each stop over along
1058
+ * its normal. {@link PathItem#interpolate()} blends the profiles of
1059
+ * both paths at the stops of each. SVG export returns paths without the
1060
+ * profile.
1061
+ *
1062
+ * @example
1063
+ * var path = Path.line([20, 50], [180, 50]);
1064
+ * path.strokeColor = 'black';
1065
+ * path.strokeWidth = 10;
1066
+ * // Taper the stroke from half its width to twice its width:
1067
+ * path.strokeProfile = [
1068
+ * { offset: 0, width: 0.5 },
1069
+ * { offset: path.length, width: 2 }
1070
+ * ];
1071
+ * console.log(path.getStrokeProfileAt(80).width); // 1.25
1072
+ */
1073
+ get strokeProfile(): StrokeProfileStop[] | null;
1074
+ set strokeProfile(stops: (StrokeProfileStop | StrokeProfileStopProps)[] | null);
1075
+ /**
1076
+ * Returns the pen of the {@link #strokeProfile} at the given offset
1077
+ * along the path, as a stop that isn't on the path, with all its
1078
+ * values: its width as a factor of the {@link Style#strokeWidth}, its
1079
+ * aspect and its angle, `1`, `1` and `0` where no stop sets them.
1080
+ * Where the profile has a step, it returns the values after it. Adding
1081
+ * the stop to the profile keeps the values at the offset, and where
1082
+ * they change in straight lines, also around it if the stop isn't
1083
+ * smooth. As a smooth stop, the values ease into it and out of it.
1084
+ *
1085
+ * @param offset the offset on the path, where `0` is at the
1086
+ * beginning of the path and {@link Path#length} at the end
1087
+ * @return the pen at the offset
1088
+ *
1089
+ * @example
1090
+ * var path = Path.line([20, 50], [180, 50]);
1091
+ * path.strokeProfile = [
1092
+ * { offset: 0, width: 0.5 },
1093
+ * { offset: path.length, width: 2, angle: 90 }
1094
+ * ];
1095
+ * // Add a stop halfway, with the values there:
1096
+ * var stop = path.getStrokeProfileAt(path.length / 2);
1097
+ * console.log(stop.width, stop.aspect, stop.angle); // 1.25 1 90
1098
+ * path.strokeProfile = path.strokeProfile.concat(stop);
1099
+ */
1100
+ getStrokeProfileAt(offset: number): StrokeProfileStop;
1101
+ /**
1102
+ * Calculates the point on the path at the given offset.
1103
+ *
1104
+ * @param offset the offset on the path, where `0` is at
1105
+ * the beginning of the path and {@link Path#length} at the end
1106
+ * @return the point at the given offset
1107
+ *
1108
+ * @example {@paperscript height=150}
1109
+ * // Finding the point on a path at a given offset:
1110
+ *
1111
+ * // Create an arc shaped path:
1112
+ * var path = new Path({
1113
+ * strokeColor: 'black'
1114
+ * });
1115
+ *
1116
+ * path.add(new Point(40, 100));
1117
+ * path.arcTo(new Point(150, 100));
1118
+ *
1119
+ * // We're going to be working with a third of the length
1120
+ * // of the path as the offset:
1121
+ * var offset = path.length / 3;
1122
+ *
1123
+ * // Find the point on the path:
1124
+ * var point = path.getPointAt(offset);
1125
+ *
1126
+ * // Create a small circle shaped path at the point:
1127
+ * var circle = Path.circle({
1128
+ * center: point,
1129
+ * radius: 3,
1130
+ * fillColor: 'red'
1131
+ * });
1132
+ *
1133
+ * @example {@paperscript height=150}
1134
+ * // Iterating over the length of a path:
1135
+ *
1136
+ * // Create an arc shaped path:
1137
+ * var path = new Path({
1138
+ * strokeColor: 'black'
1139
+ * });
1140
+ *
1141
+ * path.add(new Point(40, 100));
1142
+ * path.arcTo(new Point(150, 100));
1143
+ *
1144
+ * var amount = 5;
1145
+ * var length = path.length;
1146
+ * for (var i = 0; i < amount + 1; i++) {
1147
+ * var offset = i / amount * length;
1148
+ *
1149
+ * // Find the point on the path at the given offset:
1150
+ * var point = path.getPointAt(offset);
1151
+ *
1152
+ * // Create a small circle shaped path at the point:
1153
+ * var circle = Path.circle({
1154
+ * center: point,
1155
+ * radius: 3,
1156
+ * fillColor: 'red'
1157
+ * });
1158
+ * }
1159
+ */
1160
+ getPointAt(offset: number | CurveLocation): Point | null;
1161
+ /**
1162
+ * Calculates the normalized tangent vector of the path at the given offset.
1163
+ *
1164
+ * @param offset the offset on the path, where `0` is at
1165
+ * the beginning of the path and {@link Path#length} at the end
1166
+ * @return the normalized tangent vector at the given offset
1167
+ *
1168
+ * @example {@paperscript height=150}
1169
+ * // Working with the tangent vector at a given offset:
1170
+ *
1171
+ * // Create an arc shaped path:
1172
+ * var path = new Path({
1173
+ * strokeColor: 'black'
1174
+ * });
1175
+ *
1176
+ * path.add(new Point(40, 100));
1177
+ * path.arcTo(new Point(150, 100));
1178
+ *
1179
+ * // We're going to be working with a third of the length
1180
+ * // of the path as the offset:
1181
+ * var offset = path.length / 3;
1182
+ *
1183
+ * // Find the point on the path:
1184
+ * var point = path.getPointAt(offset);
1185
+ *
1186
+ * // Find the tangent vector at the given offset
1187
+ * // and give it a length of 60:
1188
+ * var tangent = path.getTangentAt(offset) * 60;
1189
+ *
1190
+ * var line = new Path({
1191
+ * segments: [point, point + tangent],
1192
+ * strokeColor: 'red'
1193
+ * })
1194
+ *
1195
+ * @example {@paperscript height=200}
1196
+ * // Iterating over the length of a path:
1197
+ *
1198
+ * // Create an arc shaped path:
1199
+ * var path = new Path({
1200
+ * strokeColor: 'black'
1201
+ * });
1202
+ *
1203
+ * path.add(new Point(40, 100));
1204
+ * path.arcTo(new Point(150, 100));
1205
+ *
1206
+ * var amount = 6;
1207
+ * var length = path.length;
1208
+ * for (var i = 0; i < amount + 1; i++) {
1209
+ * var offset = i / amount * length;
1210
+ *
1211
+ * // Find the point on the path at the given offset:
1212
+ * var point = path.getPointAt(offset);
1213
+ *
1214
+ * // Find the tangent vector on the path at the given offset
1215
+ * // and give it a length of 60:
1216
+ * var tangent = path.getTangentAt(offset) * 60;
1217
+ *
1218
+ * var line = new Path({
1219
+ * segments: [point, point + tangent],
1220
+ * strokeColor: 'red'
1221
+ * })
1222
+ * }
1223
+ */
1224
+ getTangentAt(offset: number | CurveLocation): Point | null;
1225
+ /**
1226
+ * Calculates the normal vector of the path at the given offset.
1227
+ *
1228
+ * @param offset the offset on the path, where `0` is at
1229
+ * the beginning of the path and {@link Path#length} at the end
1230
+ * @return the normal vector at the given offset
1231
+ *
1232
+ * @example {@paperscript height=150}
1233
+ * // Working with the normal vector at a given offset:
1234
+ *
1235
+ * // Create an arc shaped path:
1236
+ * var path = new Path({
1237
+ * strokeColor: 'black'
1238
+ * });
1239
+ *
1240
+ * path.add(new Point(40, 100));
1241
+ * path.arcTo(new Point(150, 100));
1242
+ *
1243
+ * // We're going to be working with a third of the length
1244
+ * // of the path as the offset:
1245
+ * var offset = path.length / 3;
1246
+ *
1247
+ * // Find the point on the path:
1248
+ * var point = path.getPointAt(offset);
1249
+ *
1250
+ * // Find the normal vector on the path at the given offset
1251
+ * // and give it a length of 30:
1252
+ * var normal = path.getNormalAt(offset) * 30;
1253
+ *
1254
+ * var line = new Path({
1255
+ * segments: [point, point + normal],
1256
+ * strokeColor: 'red'
1257
+ * });
1258
+ *
1259
+ * @example {@paperscript height=200}
1260
+ * // Iterating over the length of a path:
1261
+ *
1262
+ * // Create an arc shaped path:
1263
+ * var path = new Path({
1264
+ * strokeColor: 'black'
1265
+ * });
1266
+ *
1267
+ * path.add(new Point(40, 100));
1268
+ * path.arcTo(new Point(150, 100));
1269
+ *
1270
+ * var amount = 10;
1271
+ * var length = path.length;
1272
+ * for (var i = 0; i < amount + 1; i++) {
1273
+ * var offset = i / amount * length;
1274
+ *
1275
+ * // Find the point on the path at the given offset:
1276
+ * var point = path.getPointAt(offset);
1277
+ *
1278
+ * // Find the normal vector on the path at the given offset
1279
+ * // and give it a length of 30:
1280
+ * var normal = path.getNormalAt(offset) * 30;
1281
+ *
1282
+ * var line = new Path({
1283
+ * segments: [point, point + normal],
1284
+ * strokeColor: 'red'
1285
+ * });
1286
+ * }
1287
+ */
1288
+ getNormalAt(offset: number | CurveLocation): Point | null;
1289
+ /**
1290
+ * Calculates the weighted tangent vector of the path at the given offset.
1291
+ *
1292
+ * @param offset the offset on the path, where `0` is at
1293
+ * the beginning of the path and {@link Path#length} at the end
1294
+ * @return the weighted tangent vector at the given offset, or `null` if the
1295
+ * offset is beyond the path
1296
+ */
1297
+ getWeightedTangentAt(offset: number | CurveLocation): Point | null;
1298
+ /**
1299
+ * Calculates the weighted normal vector of the path at the given offset.
1300
+ *
1301
+ * @param offset the offset on the path, where `0` is at
1302
+ * the beginning of the path and {@link Path#length} at the end
1303
+ * @return the weighted normal vector at the given offset, or `null` if the
1304
+ * offset is beyond the path
1305
+ */
1306
+ getWeightedNormalAt(offset: number | CurveLocation): Point | null;
1307
+ /**
1308
+ * Calculates the curvature of the path at the given offset. Curvatures
1309
+ * indicate how sharply a path changes direction. A straight line has zero
1310
+ * curvature, where as a circle has a constant curvature. The path's radius
1311
+ * at the given offset is the reciprocal value of its curvature.
1312
+ *
1313
+ * @param offset the offset on the path, where `0` is at
1314
+ * the beginning of the path and {@link Path#length} at the end
1315
+ * @return the curvature at the given offset, or `null` if the offset is
1316
+ * beyond the path
1317
+ */
1318
+ getCurvatureAt(offset: number | CurveLocation): number | null;
1319
+ }
1320
+ export interface Path {
1321
+ /**
1322
+ * Specifies whether a path is selected and will also return `true` if the
1323
+ * path is partially selected, i.e. one or more of its segments is selected.
1324
+ *
1325
+ * Paper.js draws the visual outlines of selected items on top of your
1326
+ * project. This can be useful for debugging, as it allows you to see the
1327
+ * construction of paths, position of path curves, individual segment points
1328
+ * and bounding boxes of symbol and raster items.
1329
+ *
1330
+ * @see Project#selectedItems
1331
+ * @see Segment#selected
1332
+ * @see SelectablePoint#selected
1333
+ *
1334
+ * @example {@paperscript}
1335
+ * // Selecting an item:
1336
+ * var path = Path.circle({
1337
+ * center: [80, 50],
1338
+ * radius: 35
1339
+ * });
1340
+ * path.selected = true; // Select the path
1341
+ *
1342
+ * @example {@paperscript}
1343
+ * // A path is selected, if one or more of its segments is selected:
1344
+ * var path = Path.circle({
1345
+ * center: [80, 50],
1346
+ * radius: 35
1347
+ * });
1348
+ *
1349
+ * // Select the second segment of the path:
1350
+ * path.segments[1].selected = true;
1351
+ *
1352
+ * // If the path is selected (which it is), set its fill color to red:
1353
+ * if (path.selected) {
1354
+ * path.fillColor = 'red';
1355
+ * }
1356
+ *
1357
+ */
1358
+ get selected(): boolean;
1359
+ set selected(selected: boolean);
1360
+ }
1361
+ export declare function getCommandPoints(args: (PointLike | number)[], count: number): Point[];