@linkiez/dxf-renew 5.3.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 (447) hide show
  1. package/.eslintignore +17 -0
  2. package/.eslintrc.json +61 -0
  3. package/.gitattributes +4 -0
  4. package/.github/instructions/project-en_US.instructions.md +352 -0
  5. package/.github/workflows/release.yml +110 -0
  6. package/.husky/commit-msg +4 -0
  7. package/.husky/pre-commit +1 -0
  8. package/.prettierignore +1 -0
  9. package/.prettierrc.json +6 -0
  10. package/.releaserc.json +76 -0
  11. package/.travis.yml +6 -0
  12. package/.yarn/install-state.gz +0 -0
  13. package/.yarnrc.yml +1 -0
  14. package/CHANGELOG.md +134 -0
  15. package/CONTRIBUTING.md +271 -0
  16. package/LICENSE +21 -0
  17. package/PLAN.md +517 -0
  18. package/README.md +306 -0
  19. package/build.mjs +66 -0
  20. package/commitlint.config.js +25 -0
  21. package/dist/dxf.js +7234 -0
  22. package/docs/CODE_PATTERNS.md +182 -0
  23. package/docs/DIMENSION_SUMMARY.md +248 -0
  24. package/docs/DIMENSION_SUMMARY.pt-BR.md +248 -0
  25. package/docs/IMPLEMENTED-2D-ENTITIES.md +54 -0
  26. package/docs/IMPLEMENTED-2D-ENTITIES.pt-BR.md +54 -0
  27. package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +241 -0
  28. package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.pt-BR.md +169 -0
  29. package/docs/autocad_2012_pdf_dxf-reference_enu.md +8272 -0
  30. package/examples/dxf.html +36 -0
  31. package/examples/example.es5.js +30 -0
  32. package/examples/example.es6.js +30 -0
  33. package/examples/text-dimension-viewer.html +133 -0
  34. package/lib/Helper.cjs +89 -0
  35. package/lib/Helper.cjs.map +7 -0
  36. package/lib/Helper.js +59 -0
  37. package/lib/Helper.js.map +7 -0
  38. package/lib/applyTransforms.cjs +59 -0
  39. package/lib/applyTransforms.cjs.map +7 -0
  40. package/lib/applyTransforms.js +39 -0
  41. package/lib/applyTransforms.js.map +7 -0
  42. package/lib/cli.cjs +53 -0
  43. package/lib/cli.cjs.map +7 -0
  44. package/lib/cli.js +29 -0
  45. package/lib/cli.js.map +7 -0
  46. package/lib/config.cjs +30 -0
  47. package/lib/config.cjs.map +7 -0
  48. package/lib/config.js +10 -0
  49. package/lib/config.js.map +7 -0
  50. package/lib/constants.cjs +39 -0
  51. package/lib/constants.cjs.map +7 -0
  52. package/lib/constants.js +15 -0
  53. package/lib/constants.js.map +7 -0
  54. package/lib/denormalise.cjs +148 -0
  55. package/lib/denormalise.cjs.map +7 -0
  56. package/lib/denormalise.js +118 -0
  57. package/lib/denormalise.js.map +7 -0
  58. package/lib/dimensionToSVG.cjs +307 -0
  59. package/lib/dimensionToSVG.cjs.map +7 -0
  60. package/lib/dimensionToSVG.js +273 -0
  61. package/lib/dimensionToSVG.js.map +7 -0
  62. package/lib/entityToPolyline.cjs +248 -0
  63. package/lib/entityToPolyline.cjs.map +7 -0
  64. package/lib/entityToPolyline.js +213 -0
  65. package/lib/entityToPolyline.js.map +7 -0
  66. package/lib/getRGBForEntity.cjs +53 -0
  67. package/lib/getRGBForEntity.cjs.map +7 -0
  68. package/lib/getRGBForEntity.js +23 -0
  69. package/lib/getRGBForEntity.js.map +7 -0
  70. package/lib/groupEntitiesByLayer.cjs +34 -0
  71. package/lib/groupEntitiesByLayer.cjs.map +7 -0
  72. package/lib/groupEntitiesByLayer.js +14 -0
  73. package/lib/groupEntitiesByLayer.js.map +7 -0
  74. package/lib/handlers/blocks.cjs +93 -0
  75. package/lib/handlers/blocks.cjs.map +7 -0
  76. package/lib/handlers/blocks.js +63 -0
  77. package/lib/handlers/blocks.js.map +7 -0
  78. package/lib/handlers/entities.cjs +118 -0
  79. package/lib/handlers/entities.cjs.map +7 -0
  80. package/lib/handlers/entities.js +88 -0
  81. package/lib/handlers/entities.js.map +7 -0
  82. package/lib/handlers/entity/arc.cjs +82 -0
  83. package/lib/handlers/entity/arc.cjs.map +7 -0
  84. package/lib/handlers/entity/arc.js +47 -0
  85. package/lib/handlers/entity/arc.js.map +7 -0
  86. package/lib/handlers/entity/attdef.cjs +318 -0
  87. package/lib/handlers/entity/attdef.cjs.map +7 -0
  88. package/lib/handlers/entity/attdef.js +282 -0
  89. package/lib/handlers/entity/attdef.js.map +7 -0
  90. package/lib/handlers/entity/attrib.cjs +52 -0
  91. package/lib/handlers/entity/attrib.cjs.map +7 -0
  92. package/lib/handlers/entity/attrib.js +27 -0
  93. package/lib/handlers/entity/attrib.js.map +7 -0
  94. package/lib/handlers/entity/circle.cjs +73 -0
  95. package/lib/handlers/entity/circle.cjs.map +7 -0
  96. package/lib/handlers/entity/circle.js +38 -0
  97. package/lib/handlers/entity/circle.js.map +7 -0
  98. package/lib/handlers/entity/common.cjs +83 -0
  99. package/lib/handlers/entity/common.cjs.map +7 -0
  100. package/lib/handlers/entity/common.js +63 -0
  101. package/lib/handlers/entity/common.js.map +7 -0
  102. package/lib/handlers/entity/dimension.cjs +203 -0
  103. package/lib/handlers/entity/dimension.cjs.map +7 -0
  104. package/lib/handlers/entity/dimension.js +168 -0
  105. package/lib/handlers/entity/dimension.js.map +7 -0
  106. package/lib/handlers/entity/ellipse.cjs +88 -0
  107. package/lib/handlers/entity/ellipse.cjs.map +7 -0
  108. package/lib/handlers/entity/ellipse.js +53 -0
  109. package/lib/handlers/entity/ellipse.js.map +7 -0
  110. package/lib/handlers/entity/hatch.cjs +470 -0
  111. package/lib/handlers/entity/hatch.cjs.map +7 -0
  112. package/lib/handlers/entity/hatch.js +435 -0
  113. package/lib/handlers/entity/hatch.js.map +7 -0
  114. package/lib/handlers/entity/insert.cjs +106 -0
  115. package/lib/handlers/entity/insert.cjs.map +7 -0
  116. package/lib/handlers/entity/insert.js +71 -0
  117. package/lib/handlers/entity/insert.js.map +7 -0
  118. package/lib/handlers/entity/line.cjs +84 -0
  119. package/lib/handlers/entity/line.cjs.map +7 -0
  120. package/lib/handlers/entity/line.js +49 -0
  121. package/lib/handlers/entity/line.js.map +7 -0
  122. package/lib/handlers/entity/lwpolyline.cjs +82 -0
  123. package/lib/handlers/entity/lwpolyline.cjs.map +7 -0
  124. package/lib/handlers/entity/lwpolyline.js +47 -0
  125. package/lib/handlers/entity/lwpolyline.js.map +7 -0
  126. package/lib/handlers/entity/mtext.cjs +121 -0
  127. package/lib/handlers/entity/mtext.cjs.map +7 -0
  128. package/lib/handlers/entity/mtext.js +85 -0
  129. package/lib/handlers/entity/mtext.js.map +7 -0
  130. package/lib/handlers/entity/ole2Frame.cjs +98 -0
  131. package/lib/handlers/entity/ole2Frame.cjs.map +7 -0
  132. package/lib/handlers/entity/ole2Frame.js +63 -0
  133. package/lib/handlers/entity/ole2Frame.js.map +7 -0
  134. package/lib/handlers/entity/point.cjs +73 -0
  135. package/lib/handlers/entity/point.cjs.map +7 -0
  136. package/lib/handlers/entity/point.js +38 -0
  137. package/lib/handlers/entity/point.js.map +7 -0
  138. package/lib/handlers/entity/polyline.cjs +70 -0
  139. package/lib/handlers/entity/polyline.cjs.map +7 -0
  140. package/lib/handlers/entity/polyline.js +35 -0
  141. package/lib/handlers/entity/polyline.js.map +7 -0
  142. package/lib/handlers/entity/solid.cjs +101 -0
  143. package/lib/handlers/entity/solid.cjs.map +7 -0
  144. package/lib/handlers/entity/solid.js +66 -0
  145. package/lib/handlers/entity/solid.js.map +7 -0
  146. package/lib/handlers/entity/spline.cjs +109 -0
  147. package/lib/handlers/entity/spline.cjs.map +7 -0
  148. package/lib/handlers/entity/spline.js +74 -0
  149. package/lib/handlers/entity/spline.js.map +7 -0
  150. package/lib/handlers/entity/text.cjs +85 -0
  151. package/lib/handlers/entity/text.cjs.map +7 -0
  152. package/lib/handlers/entity/text.js +49 -0
  153. package/lib/handlers/entity/text.js.map +7 -0
  154. package/lib/handlers/entity/threeDFace.cjs +98 -0
  155. package/lib/handlers/entity/threeDFace.cjs.map +7 -0
  156. package/lib/handlers/entity/threeDFace.js +63 -0
  157. package/lib/handlers/entity/threeDFace.js.map +7 -0
  158. package/lib/handlers/entity/vertex.cjs +78 -0
  159. package/lib/handlers/entity/vertex.cjs.map +7 -0
  160. package/lib/handlers/entity/vertex.js +53 -0
  161. package/lib/handlers/entity/vertex.js.map +7 -0
  162. package/lib/handlers/entity/viewport.cjs +153 -0
  163. package/lib/handlers/entity/viewport.cjs.map +7 -0
  164. package/lib/handlers/entity/viewport.js +118 -0
  165. package/lib/handlers/entity/viewport.js.map +7 -0
  166. package/lib/handlers/header.cjs +92 -0
  167. package/lib/handlers/header.cjs.map +7 -0
  168. package/lib/handlers/header.js +72 -0
  169. package/lib/handlers/header.js.map +7 -0
  170. package/lib/handlers/objects.cjs +170 -0
  171. package/lib/handlers/objects.cjs.map +7 -0
  172. package/lib/handlers/objects.js +150 -0
  173. package/lib/handlers/objects.js.map +7 -0
  174. package/lib/handlers/tables.cjs +587 -0
  175. package/lib/handlers/tables.cjs.map +7 -0
  176. package/lib/handlers/tables.js +557 -0
  177. package/lib/handlers/tables.js.map +7 -0
  178. package/lib/index.cjs +60 -0
  179. package/lib/index.cjs.map +7 -0
  180. package/lib/index.js +19 -0
  181. package/lib/index.js.map +7 -0
  182. package/lib/parseString.cjs +118 -0
  183. package/lib/parseString.cjs.map +7 -0
  184. package/lib/parseString.js +88 -0
  185. package/lib/parseString.js.map +7 -0
  186. package/lib/toPolylines.cjs +69 -0
  187. package/lib/toPolylines.cjs.map +7 -0
  188. package/lib/toPolylines.js +39 -0
  189. package/lib/toPolylines.js.map +7 -0
  190. package/lib/toSVG.cjs +395 -0
  191. package/lib/toSVG.cjs.map +7 -0
  192. package/lib/toSVG.js +361 -0
  193. package/lib/toSVG.js.map +7 -0
  194. package/lib/types/arc-entity.cjs +17 -0
  195. package/lib/types/arc-entity.cjs.map +7 -0
  196. package/lib/types/arc-entity.js +1 -0
  197. package/lib/types/arc-entity.js.map +7 -0
  198. package/lib/types/base-entity.cjs +17 -0
  199. package/lib/types/base-entity.cjs.map +7 -0
  200. package/lib/types/base-entity.js +1 -0
  201. package/lib/types/base-entity.js.map +7 -0
  202. package/lib/types/circle-entity.cjs +17 -0
  203. package/lib/types/circle-entity.cjs.map +7 -0
  204. package/lib/types/circle-entity.js +1 -0
  205. package/lib/types/circle-entity.js.map +7 -0
  206. package/lib/types/common.cjs +17 -0
  207. package/lib/types/common.cjs.map +7 -0
  208. package/lib/types/common.js +1 -0
  209. package/lib/types/common.js.map +7 -0
  210. package/lib/types/dimension-entity.cjs +17 -0
  211. package/lib/types/dimension-entity.cjs.map +7 -0
  212. package/lib/types/dimension-entity.js +1 -0
  213. package/lib/types/dimension-entity.js.map +7 -0
  214. package/lib/types/dxf.cjs +17 -0
  215. package/lib/types/dxf.cjs.map +7 -0
  216. package/lib/types/dxf.js +1 -0
  217. package/lib/types/dxf.js.map +7 -0
  218. package/lib/types/ellipse-entity.cjs +17 -0
  219. package/lib/types/ellipse-entity.cjs.map +7 -0
  220. package/lib/types/ellipse-entity.js +1 -0
  221. package/lib/types/ellipse-entity.js.map +7 -0
  222. package/lib/types/entity.cjs +17 -0
  223. package/lib/types/entity.cjs.map +7 -0
  224. package/lib/types/entity.js +1 -0
  225. package/lib/types/entity.js.map +7 -0
  226. package/lib/types/handler-internal.cjs +17 -0
  227. package/lib/types/handler-internal.cjs.map +7 -0
  228. package/lib/types/handler-internal.js +1 -0
  229. package/lib/types/handler-internal.js.map +7 -0
  230. package/lib/types/handler.cjs +17 -0
  231. package/lib/types/handler.cjs.map +7 -0
  232. package/lib/types/handler.js +1 -0
  233. package/lib/types/handler.js.map +7 -0
  234. package/lib/types/hatch-entity.cjs +17 -0
  235. package/lib/types/hatch-entity.cjs.map +7 -0
  236. package/lib/types/hatch-entity.js +1 -0
  237. package/lib/types/hatch-entity.js.map +7 -0
  238. package/lib/types/helper.cjs +17 -0
  239. package/lib/types/helper.cjs.map +7 -0
  240. package/lib/types/helper.js +1 -0
  241. package/lib/types/helper.js.map +7 -0
  242. package/lib/types/index.cjs +77 -0
  243. package/lib/types/index.cjs.map +7 -0
  244. package/lib/types/index.js +29 -0
  245. package/lib/types/index.js.map +7 -0
  246. package/lib/types/insert-entity.cjs +17 -0
  247. package/lib/types/insert-entity.cjs.map +7 -0
  248. package/lib/types/insert-entity.js +1 -0
  249. package/lib/types/insert-entity.js.map +7 -0
  250. package/lib/types/layer-groups.cjs +17 -0
  251. package/lib/types/layer-groups.cjs.map +7 -0
  252. package/lib/types/layer-groups.js +1 -0
  253. package/lib/types/layer-groups.js.map +7 -0
  254. package/lib/types/line-entity.cjs +17 -0
  255. package/lib/types/line-entity.cjs.map +7 -0
  256. package/lib/types/line-entity.js +1 -0
  257. package/lib/types/line-entity.js.map +7 -0
  258. package/lib/types/mtext-entity.cjs +17 -0
  259. package/lib/types/mtext-entity.cjs.map +7 -0
  260. package/lib/types/mtext-entity.js +1 -0
  261. package/lib/types/mtext-entity.js.map +7 -0
  262. package/lib/types/ole2frame-entity.cjs +17 -0
  263. package/lib/types/ole2frame-entity.cjs.map +7 -0
  264. package/lib/types/ole2frame-entity.js +1 -0
  265. package/lib/types/ole2frame-entity.js.map +7 -0
  266. package/lib/types/options.cjs +17 -0
  267. package/lib/types/options.cjs.map +7 -0
  268. package/lib/types/options.js +1 -0
  269. package/lib/types/options.js.map +7 -0
  270. package/lib/types/point-entity.cjs +17 -0
  271. package/lib/types/point-entity.cjs.map +7 -0
  272. package/lib/types/point-entity.js +1 -0
  273. package/lib/types/point-entity.js.map +7 -0
  274. package/lib/types/polyline-entity.cjs +17 -0
  275. package/lib/types/polyline-entity.cjs.map +7 -0
  276. package/lib/types/polyline-entity.js +1 -0
  277. package/lib/types/polyline-entity.js.map +7 -0
  278. package/lib/types/polylines.cjs +17 -0
  279. package/lib/types/polylines.cjs.map +7 -0
  280. package/lib/types/polylines.js +1 -0
  281. package/lib/types/polylines.js.map +7 -0
  282. package/lib/types/solid-entity.cjs +17 -0
  283. package/lib/types/solid-entity.cjs.map +7 -0
  284. package/lib/types/solid-entity.js +1 -0
  285. package/lib/types/solid-entity.js.map +7 -0
  286. package/lib/types/spline-entity.cjs +17 -0
  287. package/lib/types/spline-entity.cjs.map +7 -0
  288. package/lib/types/spline-entity.js +1 -0
  289. package/lib/types/spline-entity.js.map +7 -0
  290. package/lib/types/svg.cjs +17 -0
  291. package/lib/types/svg.cjs.map +7 -0
  292. package/lib/types/svg.js +1 -0
  293. package/lib/types/svg.js.map +7 -0
  294. package/lib/types/tables.cjs +17 -0
  295. package/lib/types/tables.cjs.map +7 -0
  296. package/lib/types/tables.js +1 -0
  297. package/lib/types/tables.js.map +7 -0
  298. package/lib/types/text-entity.cjs +17 -0
  299. package/lib/types/text-entity.cjs.map +7 -0
  300. package/lib/types/text-entity.js +1 -0
  301. package/lib/types/text-entity.js.map +7 -0
  302. package/lib/types/util-types.cjs +17 -0
  303. package/lib/types/util-types.cjs.map +7 -0
  304. package/lib/types/util-types.js +1 -0
  305. package/lib/types/util-types.js.map +7 -0
  306. package/lib/types/vecks.d.cjs +2 -0
  307. package/lib/types/vecks.d.cjs.map +7 -0
  308. package/lib/types/vecks.d.js +1 -0
  309. package/lib/types/vecks.d.js.map +7 -0
  310. package/lib/types/viewport-entity.cjs +17 -0
  311. package/lib/types/viewport-entity.cjs.map +7 -0
  312. package/lib/types/viewport-entity.js +1 -0
  313. package/lib/types/viewport-entity.js.map +7 -0
  314. package/lib/types.cjs +23 -0
  315. package/lib/types.cjs.map +7 -0
  316. package/lib/types.js +2 -0
  317. package/lib/types.js.map +7 -0
  318. package/lib/util/bSpline.cjs +95 -0
  319. package/lib/util/bSpline.cjs.map +7 -0
  320. package/lib/util/bSpline.js +65 -0
  321. package/lib/util/bSpline.js.map +7 -0
  322. package/lib/util/colors.cjs +283 -0
  323. package/lib/util/colors.cjs.map +7 -0
  324. package/lib/util/colors.js +263 -0
  325. package/lib/util/colors.js.map +7 -0
  326. package/lib/util/createArcForLWPolyline.cjs +84 -0
  327. package/lib/util/createArcForLWPolyline.cjs.map +7 -0
  328. package/lib/util/createArcForLWPolyline.js +64 -0
  329. package/lib/util/createArcForLWPolyline.js.map +7 -0
  330. package/lib/util/dxfColorToRGB.cjs +115 -0
  331. package/lib/util/dxfColorToRGB.cjs.map +7 -0
  332. package/lib/util/dxfColorToRGB.js +90 -0
  333. package/lib/util/dxfColorToRGB.js.map +7 -0
  334. package/lib/util/insertKnot.cjs +77 -0
  335. package/lib/util/insertKnot.cjs.map +7 -0
  336. package/lib/util/insertKnot.js +57 -0
  337. package/lib/util/insertKnot.js.map +7 -0
  338. package/lib/util/logger.cjs +53 -0
  339. package/lib/util/logger.cjs.map +7 -0
  340. package/lib/util/logger.js +23 -0
  341. package/lib/util/logger.js.map +7 -0
  342. package/lib/util/rgbToColorAttribute.cjs +32 -0
  343. package/lib/util/rgbToColorAttribute.cjs.map +7 -0
  344. package/lib/util/rgbToColorAttribute.js +12 -0
  345. package/lib/util/rgbToColorAttribute.js.map +7 -0
  346. package/lib/util/rotate.cjs +30 -0
  347. package/lib/util/rotate.cjs.map +7 -0
  348. package/lib/util/rotate.js +10 -0
  349. package/lib/util/rotate.js.map +7 -0
  350. package/lib/util/round10.cjs +38 -0
  351. package/lib/util/round10.cjs.map +7 -0
  352. package/lib/util/round10.js +18 -0
  353. package/lib/util/round10.js.map +7 -0
  354. package/lib/util/toPiecewiseBezier.cjs +90 -0
  355. package/lib/util/toPiecewiseBezier.cjs.map +7 -0
  356. package/lib/util/toPiecewiseBezier.js +54 -0
  357. package/lib/util/toPiecewiseBezier.js.map +7 -0
  358. package/lib/util/transformBoundingBoxAndElement.cjs +80 -0
  359. package/lib/util/transformBoundingBoxAndElement.cjs.map +7 -0
  360. package/lib/util/transformBoundingBoxAndElement.js +60 -0
  361. package/lib/util/transformBoundingBoxAndElement.js.map +7 -0
  362. package/package.json +127 -0
  363. package/src/Helper.ts +71 -0
  364. package/src/applyTransforms.ts +54 -0
  365. package/src/cli.ts +41 -0
  366. package/src/config.ts +10 -0
  367. package/src/constants.ts +14 -0
  368. package/src/denormalise.ts +153 -0
  369. package/src/dimensionToSVG.ts +427 -0
  370. package/src/entityToPolyline.ts +338 -0
  371. package/src/getRGBForEntity.ts +28 -0
  372. package/src/groupEntitiesByLayer.ts +14 -0
  373. package/src/handlers/blocks.ts +65 -0
  374. package/src/handlers/entities.ts +111 -0
  375. package/src/handlers/entity/arc.ts +61 -0
  376. package/src/handlers/entity/attdef.ts +284 -0
  377. package/src/handlers/entity/attrib.ts +29 -0
  378. package/src/handlers/entity/circle.ts +47 -0
  379. package/src/handlers/entity/common.ts +79 -0
  380. package/src/handlers/entity/dimension.ts +217 -0
  381. package/src/handlers/entity/ellipse.ts +55 -0
  382. package/src/handlers/entity/hatch.ts +471 -0
  383. package/src/handlers/entity/insert.ts +73 -0
  384. package/src/handlers/entity/line.ts +56 -0
  385. package/src/handlers/entity/lwpolyline.ts +54 -0
  386. package/src/handlers/entity/mtext.ts +150 -0
  387. package/src/handlers/entity/ole2Frame.ts +64 -0
  388. package/src/handlers/entity/point.ts +47 -0
  389. package/src/handlers/entity/polyline.ts +49 -0
  390. package/src/handlers/entity/solid.ts +73 -0
  391. package/src/handlers/entity/spline.ts +103 -0
  392. package/src/handlers/entity/text.ts +83 -0
  393. package/src/handlers/entity/threeDFace.ts +69 -0
  394. package/src/handlers/entity/vertex.ts +55 -0
  395. package/src/handlers/entity/viewport.ts +119 -0
  396. package/src/handlers/header.ts +73 -0
  397. package/src/handlers/objects.ts +152 -0
  398. package/src/handlers/tables.ts +581 -0
  399. package/src/index.ts +19 -0
  400. package/src/parseString.ts +97 -0
  401. package/src/toPolylines.ts +47 -0
  402. package/src/toSVG.ts +518 -0
  403. package/src/types/README.md +91 -0
  404. package/src/types/arc-entity.ts +10 -0
  405. package/src/types/base-entity.ts +25 -0
  406. package/src/types/circle-entity.ts +8 -0
  407. package/src/types/common.ts +37 -0
  408. package/src/types/dimension-entity.ts +23 -0
  409. package/src/types/dxf.ts +64 -0
  410. package/src/types/ellipse-entity.ts +13 -0
  411. package/src/types/entity.ts +32 -0
  412. package/src/types/handler-internal.ts +51 -0
  413. package/src/types/handler.ts +10 -0
  414. package/src/types/hatch-entity.ts +127 -0
  415. package/src/types/helper.ts +12 -0
  416. package/src/types/index.ts +53 -0
  417. package/src/types/insert-entity.ts +19 -0
  418. package/src/types/layer-groups.ts +8 -0
  419. package/src/types/line-entity.ts +10 -0
  420. package/src/types/mtext-entity.ts +35 -0
  421. package/src/types/ole2frame-entity.ts +35 -0
  422. package/src/types/options.ts +17 -0
  423. package/src/types/point-entity.ts +7 -0
  424. package/src/types/polyline-entity.ts +20 -0
  425. package/src/types/polylines.ts +22 -0
  426. package/src/types/solid-entity.ts +9 -0
  427. package/src/types/spline-entity.ts +12 -0
  428. package/src/types/svg.ts +31 -0
  429. package/src/types/tables.ts +414 -0
  430. package/src/types/text-entity.ts +23 -0
  431. package/src/types/util-types.ts +27 -0
  432. package/src/types/vecks.d.ts +29 -0
  433. package/src/types/viewport-entity.ts +81 -0
  434. package/src/types.ts +5 -0
  435. package/src/util/bSpline.ts +97 -0
  436. package/src/util/colors.ts +266 -0
  437. package/src/util/createArcForLWPolyline.ts +93 -0
  438. package/src/util/diagram.png +0 -0
  439. package/src/util/dxfColorToRGB.ts +106 -0
  440. package/src/util/insertKnot.ts +69 -0
  441. package/src/util/logger.ts +23 -0
  442. package/src/util/rgbToColorAttribute.ts +14 -0
  443. package/src/util/rotate.ts +14 -0
  444. package/src/util/round10.ts +24 -0
  445. package/src/util/toPiecewiseBezier.ts +70 -0
  446. package/src/util/transformBoundingBoxAndElement.ts +74 -0
  447. package/tsconfig.json +34 -0
@@ -0,0 +1,23 @@
1
+ import config from "../config";
2
+ function info(...args) {
3
+ if (config.verbose) {
4
+ console.info(...args);
5
+ }
6
+ }
7
+ function warn(...args) {
8
+ if (config.verbose) {
9
+ console.warn(...args);
10
+ }
11
+ }
12
+ function error(...args) {
13
+ console.error(...args);
14
+ }
15
+ var logger_default = {
16
+ info,
17
+ warn,
18
+ error
19
+ };
20
+ export {
21
+ logger_default as default
22
+ };
23
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/logger.ts"],
4
+ "sourcesContent": ["import config from '../config'\n\nfunction info(...args: any[]): void {\n if (config.verbose) {\n console.info(...args)\n }\n}\n\nfunction warn(...args: any[]): void {\n if (config.verbose) {\n console.warn(...args)\n }\n}\n\nfunction error(...args: any[]): void {\n console.error(...args)\n}\n\nexport default {\n info,\n warn,\n error,\n}\n"],
5
+ "mappings": "AAAA,OAAO,YAAY;AAEnB,SAAS,QAAQ,MAAmB;AAClC,MAAI,OAAO,SAAS;AAClB,YAAQ,KAAK,GAAG,IAAI;AAAA,EACtB;AACF;AAEA,SAAS,QAAQ,MAAmB;AAClC,MAAI,OAAO,SAAS;AAClB,YAAQ,KAAK,GAAG,IAAI;AAAA,EACtB;AACF;AAEA,SAAS,SAAS,MAAmB;AACnC,UAAQ,MAAM,GAAG,IAAI;AACvB;AAEA,IAAO,iBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var rgbToColorAttribute_exports = {};
20
+ __export(rgbToColorAttribute_exports, {
21
+ default: () => rgbToColorAttribute
22
+ });
23
+ module.exports = __toCommonJS(rgbToColorAttribute_exports);
24
+ function rgbToColorAttribute(rgb) {
25
+ const [r, g, b] = rgb;
26
+ if (r === 255 && g === 255 && b === 255) {
27
+ return "rgb(0, 0, 0)";
28
+ } else {
29
+ return `rgb(${r}, ${g}, ${b})`;
30
+ }
31
+ }
32
+ //# sourceMappingURL=rgbToColorAttribute.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/rgbToColorAttribute.ts"],
4
+ "sourcesContent": ["import type { ColorRGB } from './colors'\n\n/**\n * Convert a ColorRGB tuple to a CSS string definition.\n * Converts white lines to black as the default.\n */\nexport default function rgbToColorAttribute(rgb: ColorRGB): string {\n const [r, g, b] = rgb\n if (r === 255 && g === 255 && b === 255) {\n return 'rgb(0, 0, 0)'\n } else {\n return `rgb(${r}, ${g}, ${b})`\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMe,SAAR,oBAAqC,KAAuB;AACjE,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI;AAClB,MAAI,MAAM,OAAO,MAAM,OAAO,MAAM,KAAK;AACvC,WAAO;AAAA,EACT,OAAO;AACL,WAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AAAA,EAC7B;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ function rgbToColorAttribute(rgb) {
2
+ const [r, g, b] = rgb;
3
+ if (r === 255 && g === 255 && b === 255) {
4
+ return "rgb(0, 0, 0)";
5
+ } else {
6
+ return `rgb(${r}, ${g}, ${b})`;
7
+ }
8
+ }
9
+ export {
10
+ rgbToColorAttribute as default
11
+ };
12
+ //# sourceMappingURL=rgbToColorAttribute.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/rgbToColorAttribute.ts"],
4
+ "sourcesContent": ["import type { ColorRGB } from './colors'\n\n/**\n * Convert a ColorRGB tuple to a CSS string definition.\n * Converts white lines to black as the default.\n */\nexport default function rgbToColorAttribute(rgb: ColorRGB): string {\n const [r, g, b] = rgb\n if (r === 255 && g === 255 && b === 255) {\n return 'rgb(0, 0, 0)'\n } else {\n return `rgb(${r}, ${g}, ${b})`\n }\n}\n"],
5
+ "mappings": "AAMe,SAAR,oBAAqC,KAAuB;AACjE,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI;AAClB,MAAI,MAAM,OAAO,MAAM,OAAO,MAAM,KAAK;AACvC,WAAO;AAAA,EACT,OAAO;AACL,WAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AAAA,EAC7B;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var rotate_exports = {};
20
+ __export(rotate_exports, {
21
+ default: () => rotate
22
+ });
23
+ module.exports = __toCommonJS(rotate_exports);
24
+ function rotate(p, angle) {
25
+ return {
26
+ x: p.x * Math.cos(angle) - p.y * Math.sin(angle),
27
+ y: p.y * Math.cos(angle) + p.x * Math.sin(angle)
28
+ };
29
+ }
30
+ //# sourceMappingURL=rotate.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/rotate.ts"],
4
+ "sourcesContent": ["import { Point2D } from '../types'\n\n/**\n * Rotate a point by the given angle.\n *\n * @param p the point\n * @param angle the rotation angle in radians\n */\nexport default function rotate(p: Point2D, angle: number): Point2D {\n return {\n x: p.x * Math.cos(angle) - p.y * Math.sin(angle),\n y: p.y * Math.cos(angle) + p.x * Math.sin(angle),\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQe,SAAR,OAAwB,GAAY,OAAwB;AACjE,SAAO;AAAA,IACL,GAAG,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,EAAE,IAAI,KAAK,IAAI,KAAK;AAAA,IAC/C,GAAG,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,EAAE,IAAI,KAAK,IAAI,KAAK;AAAA,EACjD;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ function rotate(p, angle) {
2
+ return {
3
+ x: p.x * Math.cos(angle) - p.y * Math.sin(angle),
4
+ y: p.y * Math.cos(angle) + p.x * Math.sin(angle)
5
+ };
6
+ }
7
+ export {
8
+ rotate as default
9
+ };
10
+ //# sourceMappingURL=rotate.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/rotate.ts"],
4
+ "sourcesContent": ["import { Point2D } from '../types'\n\n/**\n * Rotate a point by the given angle.\n *\n * @param p the point\n * @param angle the rotation angle in radians\n */\nexport default function rotate(p: Point2D, angle: number): Point2D {\n return {\n x: p.x * Math.cos(angle) - p.y * Math.sin(angle),\n y: p.y * Math.cos(angle) + p.x * Math.sin(angle),\n }\n}\n"],
5
+ "mappings": "AAQe,SAAR,OAAwB,GAAY,OAAwB;AACjE,SAAO;AAAA,IACL,GAAG,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,EAAE,IAAI,KAAK,IAAI,KAAK;AAAA,IAC/C,GAAG,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,EAAE,IAAI,KAAK,IAAI,KAAK;AAAA,EACjD;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var round10_exports = {};
20
+ __export(round10_exports, {
21
+ default: () => round10
22
+ });
23
+ module.exports = __toCommonJS(round10_exports);
24
+ function round10(value, exp) {
25
+ if (exp === void 0 || +exp === 0) {
26
+ return Math.round(value);
27
+ }
28
+ const numValue = +value;
29
+ const numExp = +exp;
30
+ if (Number.isNaN(numValue) || !(typeof numExp === "number" && numExp % 1 === 0)) {
31
+ return Number.NaN;
32
+ }
33
+ let valueStr = numValue.toString().split("e");
34
+ const roundedValue = Math.round(+(valueStr[0] + "e" + (valueStr[1] ? +valueStr[1] - numExp : -numExp)));
35
+ valueStr = roundedValue.toString().split("e");
36
+ return +(valueStr[0] + "e" + (valueStr[1] ? +valueStr[1] + numExp : numExp));
37
+ }
38
+ //# sourceMappingURL=round10.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/round10.ts"],
4
+ "sourcesContent": ["// This is based on the example code found from:\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor\n// Example code on MDN is public domain or CC0 (your preference) or MIT depending when the\n// example code was added:\n// https://developer.mozilla.org/en-US/docs/MDN/About\n\nexport default function round10(value: number, exp?: number): number {\n // If the exp is undefined or zero...\n if (exp === undefined || +exp === 0) {\n return Math.round(value)\n }\n const numValue = +value\n const numExp = +exp\n // If the value is not a number or the exp is not an integer...\n if (Number.isNaN(numValue) || !(typeof numExp === 'number' && numExp % 1 === 0)) {\n return Number.NaN\n }\n // Shift\n let valueStr = numValue.toString().split('e')\n const roundedValue = Math.round(+(valueStr[0] + 'e' + (valueStr[1] ? +valueStr[1] - numExp : -numExp)))\n // Shift back\n valueStr = roundedValue.toString().split('e')\n return +(valueStr[0] + 'e' + (valueStr[1] ? +valueStr[1] + numExp : numExp))\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMe,SAAR,QAAyB,OAAe,KAAsB;AAEnE,MAAI,QAAQ,UAAa,CAAC,QAAQ,GAAG;AACnC,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AACA,QAAM,WAAW,CAAC;AAClB,QAAM,SAAS,CAAC;AAEhB,MAAI,OAAO,MAAM,QAAQ,KAAK,EAAE,OAAO,WAAW,YAAY,SAAS,MAAM,IAAI;AAC/E,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI,WAAW,SAAS,SAAS,EAAE,MAAM,GAAG;AAC5C,QAAM,eAAe,KAAK,MAAM,EAAE,SAAS,CAAC,IAAI,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,QAAQ;AAEtG,aAAW,aAAa,SAAS,EAAE,MAAM,GAAG;AAC5C,SAAO,EAAE,SAAS,CAAC,IAAI,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,SAAS;AACtE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,18 @@
1
+ function round10(value, exp) {
2
+ if (exp === void 0 || +exp === 0) {
3
+ return Math.round(value);
4
+ }
5
+ const numValue = +value;
6
+ const numExp = +exp;
7
+ if (Number.isNaN(numValue) || !(typeof numExp === "number" && numExp % 1 === 0)) {
8
+ return Number.NaN;
9
+ }
10
+ let valueStr = numValue.toString().split("e");
11
+ const roundedValue = Math.round(+(valueStr[0] + "e" + (valueStr[1] ? +valueStr[1] - numExp : -numExp)));
12
+ valueStr = roundedValue.toString().split("e");
13
+ return +(valueStr[0] + "e" + (valueStr[1] ? +valueStr[1] + numExp : numExp));
14
+ }
15
+ export {
16
+ round10 as default
17
+ };
18
+ //# sourceMappingURL=round10.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/round10.ts"],
4
+ "sourcesContent": ["// This is based on the example code found from:\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor\n// Example code on MDN is public domain or CC0 (your preference) or MIT depending when the\n// example code was added:\n// https://developer.mozilla.org/en-US/docs/MDN/About\n\nexport default function round10(value: number, exp?: number): number {\n // If the exp is undefined or zero...\n if (exp === undefined || +exp === 0) {\n return Math.round(value)\n }\n const numValue = +value\n const numExp = +exp\n // If the value is not a number or the exp is not an integer...\n if (Number.isNaN(numValue) || !(typeof numExp === 'number' && numExp % 1 === 0)) {\n return Number.NaN\n }\n // Shift\n let valueStr = numValue.toString().split('e')\n const roundedValue = Math.round(+(valueStr[0] + 'e' + (valueStr[1] ? +valueStr[1] - numExp : -numExp)))\n // Shift back\n valueStr = roundedValue.toString().split('e')\n return +(valueStr[0] + 'e' + (valueStr[1] ? +valueStr[1] + numExp : numExp))\n}\n"],
5
+ "mappings": "AAMe,SAAR,QAAyB,OAAe,KAAsB;AAEnE,MAAI,QAAQ,UAAa,CAAC,QAAQ,GAAG;AACnC,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AACA,QAAM,WAAW,CAAC;AAClB,QAAM,SAAS,CAAC;AAEhB,MAAI,OAAO,MAAM,QAAQ,KAAK,EAAE,OAAO,WAAW,YAAY,SAAS,MAAM,IAAI;AAC/E,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI,WAAW,SAAS,SAAS,EAAE,MAAM,GAAG;AAC5C,QAAM,eAAe,KAAK,MAAM,EAAE,SAAS,CAAC,IAAI,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,QAAQ;AAEtG,aAAW,aAAa,SAAS,EAAE,MAAM,GAAG;AAC5C,SAAO,EAAE,SAAS,CAAC,IAAI,OAAO,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,SAAS;AACtE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var toPiecewiseBezier_exports = {};
30
+ __export(toPiecewiseBezier_exports, {
31
+ checkPinned: () => checkPinned,
32
+ computeInsertions: () => computeInsertions,
33
+ default: () => toPiecewiseBezier,
34
+ multiplicity: () => multiplicity
35
+ });
36
+ module.exports = __toCommonJS(toPiecewiseBezier_exports);
37
+ var import_insertKnot = __toESM(require("./insertKnot"), 1);
38
+ const checkPinned = (k, knots) => {
39
+ for (let i = 1; i < k; ++i) {
40
+ if (knots[i] !== knots[0]) {
41
+ throw new Error(`not pinned. order: ${k} knots: ${knots}`);
42
+ }
43
+ }
44
+ for (let i = knots.length - 2; i > knots.length - k - 1; --i) {
45
+ if (knots[i] !== knots[knots.length - 1]) {
46
+ throw new Error(`not pinned. order: ${k} knots: ${knots}`);
47
+ }
48
+ }
49
+ };
50
+ const multiplicity = (knots, index) => {
51
+ let m = 1;
52
+ for (let i = index + 1; i < knots.length; ++i) {
53
+ if (knots[i] === knots[index]) {
54
+ ++m;
55
+ } else {
56
+ break;
57
+ }
58
+ }
59
+ return m;
60
+ };
61
+ const computeInsertions = (k, knots) => {
62
+ const inserts = [];
63
+ let i = k;
64
+ while (i < knots.length - k) {
65
+ const knot = knots[i];
66
+ const m = multiplicity(knots, i);
67
+ for (let j = 0; j < k - m - 1; ++j) {
68
+ inserts.push(knot);
69
+ }
70
+ i = i + m;
71
+ }
72
+ return inserts;
73
+ };
74
+ function toPiecewiseBezier(k, controlPoints, knots) {
75
+ checkPinned(k, knots);
76
+ const insertions = computeInsertions(k, knots);
77
+ return insertions.reduce(
78
+ (acc, tNew) => {
79
+ return (0, import_insertKnot.default)(k, acc.controlPoints, acc.knots, tNew);
80
+ },
81
+ { controlPoints, knots }
82
+ );
83
+ }
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ checkPinned,
87
+ computeInsertions,
88
+ multiplicity
89
+ });
90
+ //# sourceMappingURL=toPiecewiseBezier.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/toPiecewiseBezier.ts"],
4
+ "sourcesContent": ["import type { BezierResult, UtilPoint } from '../types/util-types'\nimport insertKnot from './insertKnot'\n\n/**\n * For a pinned spline, the knots have to be repeated k times\n * (where k is the order), at both the beginning and the end\n */\nexport const checkPinned = (k: number, knots: number[]): void => {\n // Pinned at the start\n for (let i = 1; i < k; ++i) {\n if (knots[i] !== knots[0]) {\n throw new Error(`not pinned. order: ${k} knots: ${knots}`)\n }\n }\n // Pinned at the end\n for (let i = knots.length - 2; i > knots.length - k - 1; --i) {\n if (knots[i] !== knots[knots.length - 1]) {\n throw new Error(`not pinned. order: ${k} knots: ${knots}`)\n }\n }\n}\n\nexport const multiplicity = (knots: number[], index: number): number => {\n let m = 1\n for (let i = index + 1; i < knots.length; ++i) {\n if (knots[i] === knots[index]) {\n ++m\n } else {\n break\n }\n }\n return m\n}\n\n/**\n * https://saccade.com/writing/graphics/KnotVectors.pdf\n * A quadratic piecewise Be\u0301zier knot vector with seven control points\n * will look like this [0 0 0 1 1 2 2 3 3 3]. In general, in a\n * piecewise Be\u0301zier knot vector the first k knots are the same,\n * then each subsequent group of k-1 knots is the same,\n * until you get to the end.\n */\nexport const computeInsertions = (k: number, knots: number[]): number[] => {\n const inserts: number[] = []\n let i = k\n while (i < knots.length - k) {\n const knot = knots[i]\n const m = multiplicity(knots, i)\n for (let j = 0; j < k - m - 1; ++j) {\n inserts.push(knot)\n }\n i = i + m\n }\n return inserts\n}\n\nexport default function toPiecewiseBezier(\n k: number,\n controlPoints: UtilPoint[],\n knots: number[]\n): BezierResult {\n checkPinned(k, knots)\n const insertions = computeInsertions(k, knots)\n return insertions.reduce(\n (acc, tNew) => {\n return insertKnot(k, acc.controlPoints, acc.knots, tNew)\n },\n { controlPoints, knots },\n )\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAuB;AAMhB,MAAM,cAAc,CAAC,GAAW,UAA0B;AAE/D,WAAS,IAAI,GAAG,IAAI,GAAG,EAAE,GAAG;AAC1B,QAAI,MAAM,CAAC,MAAM,MAAM,CAAC,GAAG;AACzB,YAAM,IAAI,MAAM,sBAAsB,CAAC,WAAW,KAAK,EAAE;AAAA,IAC3D;AAAA,EACF;AAEA,WAAS,IAAI,MAAM,SAAS,GAAG,IAAI,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG;AAC5D,QAAI,MAAM,CAAC,MAAM,MAAM,MAAM,SAAS,CAAC,GAAG;AACxC,YAAM,IAAI,MAAM,sBAAsB,CAAC,WAAW,KAAK,EAAE;AAAA,IAC3D;AAAA,EACF;AACF;AAEO,MAAM,eAAe,CAAC,OAAiB,UAA0B;AACtE,MAAI,IAAI;AACR,WAAS,IAAI,QAAQ,GAAG,IAAI,MAAM,QAAQ,EAAE,GAAG;AAC7C,QAAI,MAAM,CAAC,MAAM,MAAM,KAAK,GAAG;AAC7B,QAAE;AAAA,IACJ,OAAO;AACL;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAUO,MAAM,oBAAoB,CAAC,GAAW,UAA8B;AACzE,QAAM,UAAoB,CAAC;AAC3B,MAAI,IAAI;AACR,SAAO,IAAI,MAAM,SAAS,GAAG;AAC3B,UAAM,OAAO,MAAM,CAAC;AACpB,UAAM,IAAI,aAAa,OAAO,CAAC;AAC/B,aAAS,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,EAAE,GAAG;AAClC,cAAQ,KAAK,IAAI;AAAA,IACnB;AACA,QAAI,IAAI;AAAA,EACV;AACA,SAAO;AACT;AAEe,SAAR,kBACL,GACA,eACA,OACc;AACd,cAAY,GAAG,KAAK;AACpB,QAAM,aAAa,kBAAkB,GAAG,KAAK;AAC7C,SAAO,WAAW;AAAA,IAChB,CAAC,KAAK,SAAS;AACb,iBAAO,kBAAAA,SAAW,GAAG,IAAI,eAAe,IAAI,OAAO,IAAI;AAAA,IACzD;AAAA,IACA,EAAE,eAAe,MAAM;AAAA,EACzB;AACF;",
6
+ "names": ["insertKnot"]
7
+ }
@@ -0,0 +1,54 @@
1
+ import insertKnot from "./insertKnot";
2
+ const checkPinned = (k, knots) => {
3
+ for (let i = 1; i < k; ++i) {
4
+ if (knots[i] !== knots[0]) {
5
+ throw new Error(`not pinned. order: ${k} knots: ${knots}`);
6
+ }
7
+ }
8
+ for (let i = knots.length - 2; i > knots.length - k - 1; --i) {
9
+ if (knots[i] !== knots[knots.length - 1]) {
10
+ throw new Error(`not pinned. order: ${k} knots: ${knots}`);
11
+ }
12
+ }
13
+ };
14
+ const multiplicity = (knots, index) => {
15
+ let m = 1;
16
+ for (let i = index + 1; i < knots.length; ++i) {
17
+ if (knots[i] === knots[index]) {
18
+ ++m;
19
+ } else {
20
+ break;
21
+ }
22
+ }
23
+ return m;
24
+ };
25
+ const computeInsertions = (k, knots) => {
26
+ const inserts = [];
27
+ let i = k;
28
+ while (i < knots.length - k) {
29
+ const knot = knots[i];
30
+ const m = multiplicity(knots, i);
31
+ for (let j = 0; j < k - m - 1; ++j) {
32
+ inserts.push(knot);
33
+ }
34
+ i = i + m;
35
+ }
36
+ return inserts;
37
+ };
38
+ function toPiecewiseBezier(k, controlPoints, knots) {
39
+ checkPinned(k, knots);
40
+ const insertions = computeInsertions(k, knots);
41
+ return insertions.reduce(
42
+ (acc, tNew) => {
43
+ return insertKnot(k, acc.controlPoints, acc.knots, tNew);
44
+ },
45
+ { controlPoints, knots }
46
+ );
47
+ }
48
+ export {
49
+ checkPinned,
50
+ computeInsertions,
51
+ toPiecewiseBezier as default,
52
+ multiplicity
53
+ };
54
+ //# sourceMappingURL=toPiecewiseBezier.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/toPiecewiseBezier.ts"],
4
+ "sourcesContent": ["import type { BezierResult, UtilPoint } from '../types/util-types'\nimport insertKnot from './insertKnot'\n\n/**\n * For a pinned spline, the knots have to be repeated k times\n * (where k is the order), at both the beginning and the end\n */\nexport const checkPinned = (k: number, knots: number[]): void => {\n // Pinned at the start\n for (let i = 1; i < k; ++i) {\n if (knots[i] !== knots[0]) {\n throw new Error(`not pinned. order: ${k} knots: ${knots}`)\n }\n }\n // Pinned at the end\n for (let i = knots.length - 2; i > knots.length - k - 1; --i) {\n if (knots[i] !== knots[knots.length - 1]) {\n throw new Error(`not pinned. order: ${k} knots: ${knots}`)\n }\n }\n}\n\nexport const multiplicity = (knots: number[], index: number): number => {\n let m = 1\n for (let i = index + 1; i < knots.length; ++i) {\n if (knots[i] === knots[index]) {\n ++m\n } else {\n break\n }\n }\n return m\n}\n\n/**\n * https://saccade.com/writing/graphics/KnotVectors.pdf\n * A quadratic piecewise Be\u0301zier knot vector with seven control points\n * will look like this [0 0 0 1 1 2 2 3 3 3]. In general, in a\n * piecewise Be\u0301zier knot vector the first k knots are the same,\n * then each subsequent group of k-1 knots is the same,\n * until you get to the end.\n */\nexport const computeInsertions = (k: number, knots: number[]): number[] => {\n const inserts: number[] = []\n let i = k\n while (i < knots.length - k) {\n const knot = knots[i]\n const m = multiplicity(knots, i)\n for (let j = 0; j < k - m - 1; ++j) {\n inserts.push(knot)\n }\n i = i + m\n }\n return inserts\n}\n\nexport default function toPiecewiseBezier(\n k: number,\n controlPoints: UtilPoint[],\n knots: number[]\n): BezierResult {\n checkPinned(k, knots)\n const insertions = computeInsertions(k, knots)\n return insertions.reduce(\n (acc, tNew) => {\n return insertKnot(k, acc.controlPoints, acc.knots, tNew)\n },\n { controlPoints, knots },\n )\n}\n"],
5
+ "mappings": "AACA,OAAO,gBAAgB;AAMhB,MAAM,cAAc,CAAC,GAAW,UAA0B;AAE/D,WAAS,IAAI,GAAG,IAAI,GAAG,EAAE,GAAG;AAC1B,QAAI,MAAM,CAAC,MAAM,MAAM,CAAC,GAAG;AACzB,YAAM,IAAI,MAAM,sBAAsB,CAAC,WAAW,KAAK,EAAE;AAAA,IAC3D;AAAA,EACF;AAEA,WAAS,IAAI,MAAM,SAAS,GAAG,IAAI,MAAM,SAAS,IAAI,GAAG,EAAE,GAAG;AAC5D,QAAI,MAAM,CAAC,MAAM,MAAM,MAAM,SAAS,CAAC,GAAG;AACxC,YAAM,IAAI,MAAM,sBAAsB,CAAC,WAAW,KAAK,EAAE;AAAA,IAC3D;AAAA,EACF;AACF;AAEO,MAAM,eAAe,CAAC,OAAiB,UAA0B;AACtE,MAAI,IAAI;AACR,WAAS,IAAI,QAAQ,GAAG,IAAI,MAAM,QAAQ,EAAE,GAAG;AAC7C,QAAI,MAAM,CAAC,MAAM,MAAM,KAAK,GAAG;AAC7B,QAAE;AAAA,IACJ,OAAO;AACL;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAUO,MAAM,oBAAoB,CAAC,GAAW,UAA8B;AACzE,QAAM,UAAoB,CAAC;AAC3B,MAAI,IAAI;AACR,SAAO,IAAI,MAAM,SAAS,GAAG;AAC3B,UAAM,OAAO,MAAM,CAAC;AACpB,UAAM,IAAI,aAAa,OAAO,CAAC;AAC/B,aAAS,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,EAAE,GAAG;AAClC,cAAQ,KAAK,IAAI;AAAA,IACnB;AACA,QAAI,IAAI;AAAA,EACV;AACA,SAAO;AACT;AAEe,SAAR,kBACL,GACA,eACA,OACc;AACd,cAAY,GAAG,KAAK;AACpB,QAAM,aAAa,kBAAkB,GAAG,KAAK;AAC7C,SAAO,WAAW;AAAA,IAChB,CAAC,KAAK,SAAS;AACb,aAAO,WAAW,GAAG,IAAI,eAAe,IAAI,OAAO,IAAI;AAAA,IACzD;AAAA,IACA,EAAE,eAAe,MAAM;AAAA,EACzB;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var transformBoundingBoxAndElement_exports = {};
20
+ __export(transformBoundingBoxAndElement_exports, {
21
+ default: () => transformBoundingBoxAndElement
22
+ });
23
+ module.exports = __toCommonJS(transformBoundingBoxAndElement_exports);
24
+ var import_vecks = require("vecks");
25
+ function transformBoundingBoxAndElement(bbox, element, transforms) {
26
+ let transformedElement = "";
27
+ const matrices = transforms.map((transform) => {
28
+ const tx = transform.x || 0;
29
+ const ty = transform.y || 0;
30
+ const sx = transform.scaleX || 1;
31
+ const sy = transform.scaleY || 1;
32
+ const angle = (transform.rotation || 0) / 180 * Math.PI;
33
+ const { cos, sin } = Math;
34
+ let a, b, c, d, e, f;
35
+ if (transform.extrusionZ === -1) {
36
+ a = -sx * cos(angle);
37
+ b = sx * sin(angle);
38
+ c = sy * sin(angle);
39
+ d = sy * cos(angle);
40
+ e = -tx;
41
+ f = ty;
42
+ } else {
43
+ a = sx * cos(angle);
44
+ b = sx * sin(angle);
45
+ c = -sy * sin(angle);
46
+ d = sy * cos(angle);
47
+ e = tx;
48
+ f = ty;
49
+ }
50
+ return [a, b, c, d, e, f];
51
+ });
52
+ let transformedBBox = new import_vecks.Box2();
53
+ if (bbox.valid) {
54
+ let bboxPoints = [
55
+ { x: bbox.min.x, y: bbox.min.y },
56
+ { x: bbox.max.x, y: bbox.min.y },
57
+ { x: bbox.max.x, y: bbox.max.y },
58
+ { x: bbox.min.x, y: bbox.max.y }
59
+ ];
60
+ for (const [a, b, c, d, e, f] of matrices) {
61
+ bboxPoints = bboxPoints.map((point) => ({
62
+ x: point.x * a + point.y * c + e,
63
+ y: point.x * b + point.y * d + f
64
+ }));
65
+ }
66
+ transformedBBox = bboxPoints.reduce((acc, point) => {
67
+ return acc.expandByPoint(point);
68
+ }, new import_vecks.Box2());
69
+ }
70
+ matrices.reverse();
71
+ for (const [a, b, c, d, e, f] of matrices) {
72
+ transformedElement += `<g transform="matrix(${a} ${b} ${c} ${d} ${e} ${f})">`;
73
+ }
74
+ transformedElement += element;
75
+ for (const _ of matrices) {
76
+ transformedElement += "</g>";
77
+ }
78
+ return { bbox: transformedBBox, element: transformedElement };
79
+ }
80
+ //# sourceMappingURL=transformBoundingBoxAndElement.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/transformBoundingBoxAndElement.ts"],
4
+ "sourcesContent": ["import { Box2 } from 'vecks'\nimport type { Transform, TransformResult } from '../types'\n\n/**\n * Transform the bounding box and the SVG element by the given\n * transforms. The <g> element are created in reverse transform\n * order and the bounding box in the given order.\n */\nexport default function transformBoundingBoxAndElement(\n bbox: Box2,\n element: string,\n transforms: Transform[]\n): TransformResult {\n let transformedElement = ''\n const matrices = transforms.map((transform) => {\n // Create the transformation matrix\n const tx = transform.x || 0\n const ty = transform.y || 0\n const sx = transform.scaleX || 1\n const sy = transform.scaleY || 1\n const angle = ((transform.rotation || 0) / 180) * Math.PI\n const { cos, sin } = Math\n let a, b, c, d, e, f\n // In DXF an extrusionZ value of -1 denote a tranform around the Y axis.\n if (transform.extrusionZ === -1) {\n a = -sx * cos(angle)\n b = sx * sin(angle)\n c = sy * sin(angle)\n d = sy * cos(angle)\n e = -tx\n f = ty\n } else {\n a = sx * cos(angle)\n b = sx * sin(angle)\n c = -sy * sin(angle)\n d = sy * cos(angle)\n e = tx\n f = ty\n }\n return [a, b, c, d, e, f]\n })\n\n // Only transform the bounding box is it is valid (i.e. not Infinity)\n let transformedBBox = new Box2()\n if (bbox.valid) {\n let bboxPoints = [\n { x: bbox.min.x, y: bbox.min.y },\n { x: bbox.max.x, y: bbox.min.y },\n { x: bbox.max.x, y: bbox.max.y },\n { x: bbox.min.x, y: bbox.max.y },\n ]\n for (const [a, b, c, d, e, f] of matrices) {\n bboxPoints = bboxPoints.map((point) => ({\n x: point.x * a + point.y * c + e,\n y: point.x * b + point.y * d + f,\n }))\n }\n transformedBBox = bboxPoints.reduce((acc, point) => {\n return acc.expandByPoint(point)\n }, new Box2())\n }\n\n matrices.reverse()\n for (const [a, b, c, d, e, f] of matrices) {\n transformedElement += `<g transform=\"matrix(${a} ${b} ${c} ${d} ${e} ${f})\">`\n }\n transformedElement += element\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n for (const _ of matrices) {\n transformedElement += '</g>'\n }\n\n return { bbox: transformedBBox, element: transformedElement }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqB;AAQN,SAAR,+BACL,MACA,SACA,YACiB;AACjB,MAAI,qBAAqB;AACzB,QAAM,WAAW,WAAW,IAAI,CAAC,cAAc;AAE7C,UAAM,KAAK,UAAU,KAAK;AAC1B,UAAM,KAAK,UAAU,KAAK;AAC1B,UAAM,KAAK,UAAU,UAAU;AAC/B,UAAM,KAAK,UAAU,UAAU;AAC/B,UAAM,SAAU,UAAU,YAAY,KAAK,MAAO,KAAK;AACvD,UAAM,EAAE,KAAK,IAAI,IAAI;AACrB,QAAI,GAAG,GAAG,GAAG,GAAG,GAAG;AAEnB,QAAI,UAAU,eAAe,IAAI;AAC/B,UAAI,CAAC,KAAK,IAAI,KAAK;AACnB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,CAAC;AACL,UAAI;AAAA,IACN,OAAO;AACL,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,CAAC,KAAK,IAAI,KAAK;AACnB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI;AACJ,UAAI;AAAA,IACN;AACA,WAAO,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAAA,EAC1B,CAAC;AAGD,MAAI,kBAAkB,IAAI,kBAAK;AAC/B,MAAI,KAAK,OAAO;AACd,QAAI,aAAa;AAAA,MACf,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,KAAK,IAAI,EAAE;AAAA,MAC/B,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,KAAK,IAAI,EAAE;AAAA,MAC/B,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,KAAK,IAAI,EAAE;AAAA,MAC/B,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,KAAK,IAAI,EAAE;AAAA,IACjC;AACA,eAAW,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,KAAK,UAAU;AACzC,mBAAa,WAAW,IAAI,CAAC,WAAW;AAAA,QACtC,GAAG,MAAM,IAAI,IAAI,MAAM,IAAI,IAAI;AAAA,QAC/B,GAAG,MAAM,IAAI,IAAI,MAAM,IAAI,IAAI;AAAA,MACjC,EAAE;AAAA,IACJ;AACA,sBAAkB,WAAW,OAAO,CAAC,KAAK,UAAU;AAClD,aAAO,IAAI,cAAc,KAAK;AAAA,IAChC,GAAG,IAAI,kBAAK,CAAC;AAAA,EACf;AAEA,WAAS,QAAQ;AACjB,aAAW,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,KAAK,UAAU;AACzC,0BAAsB,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAAA,EAC1E;AACA,wBAAsB;AAEtB,aAAW,KAAK,UAAU;AACxB,0BAAsB;AAAA,EACxB;AAEA,SAAO,EAAE,MAAM,iBAAiB,SAAS,mBAAmB;AAC9D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,60 @@
1
+ import { Box2 } from "vecks";
2
+ function transformBoundingBoxAndElement(bbox, element, transforms) {
3
+ let transformedElement = "";
4
+ const matrices = transforms.map((transform) => {
5
+ const tx = transform.x || 0;
6
+ const ty = transform.y || 0;
7
+ const sx = transform.scaleX || 1;
8
+ const sy = transform.scaleY || 1;
9
+ const angle = (transform.rotation || 0) / 180 * Math.PI;
10
+ const { cos, sin } = Math;
11
+ let a, b, c, d, e, f;
12
+ if (transform.extrusionZ === -1) {
13
+ a = -sx * cos(angle);
14
+ b = sx * sin(angle);
15
+ c = sy * sin(angle);
16
+ d = sy * cos(angle);
17
+ e = -tx;
18
+ f = ty;
19
+ } else {
20
+ a = sx * cos(angle);
21
+ b = sx * sin(angle);
22
+ c = -sy * sin(angle);
23
+ d = sy * cos(angle);
24
+ e = tx;
25
+ f = ty;
26
+ }
27
+ return [a, b, c, d, e, f];
28
+ });
29
+ let transformedBBox = new Box2();
30
+ if (bbox.valid) {
31
+ let bboxPoints = [
32
+ { x: bbox.min.x, y: bbox.min.y },
33
+ { x: bbox.max.x, y: bbox.min.y },
34
+ { x: bbox.max.x, y: bbox.max.y },
35
+ { x: bbox.min.x, y: bbox.max.y }
36
+ ];
37
+ for (const [a, b, c, d, e, f] of matrices) {
38
+ bboxPoints = bboxPoints.map((point) => ({
39
+ x: point.x * a + point.y * c + e,
40
+ y: point.x * b + point.y * d + f
41
+ }));
42
+ }
43
+ transformedBBox = bboxPoints.reduce((acc, point) => {
44
+ return acc.expandByPoint(point);
45
+ }, new Box2());
46
+ }
47
+ matrices.reverse();
48
+ for (const [a, b, c, d, e, f] of matrices) {
49
+ transformedElement += `<g transform="matrix(${a} ${b} ${c} ${d} ${e} ${f})">`;
50
+ }
51
+ transformedElement += element;
52
+ for (const _ of matrices) {
53
+ transformedElement += "</g>";
54
+ }
55
+ return { bbox: transformedBBox, element: transformedElement };
56
+ }
57
+ export {
58
+ transformBoundingBoxAndElement as default
59
+ };
60
+ //# sourceMappingURL=transformBoundingBoxAndElement.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/util/transformBoundingBoxAndElement.ts"],
4
+ "sourcesContent": ["import { Box2 } from 'vecks'\nimport type { Transform, TransformResult } from '../types'\n\n/**\n * Transform the bounding box and the SVG element by the given\n * transforms. The <g> element are created in reverse transform\n * order and the bounding box in the given order.\n */\nexport default function transformBoundingBoxAndElement(\n bbox: Box2,\n element: string,\n transforms: Transform[]\n): TransformResult {\n let transformedElement = ''\n const matrices = transforms.map((transform) => {\n // Create the transformation matrix\n const tx = transform.x || 0\n const ty = transform.y || 0\n const sx = transform.scaleX || 1\n const sy = transform.scaleY || 1\n const angle = ((transform.rotation || 0) / 180) * Math.PI\n const { cos, sin } = Math\n let a, b, c, d, e, f\n // In DXF an extrusionZ value of -1 denote a tranform around the Y axis.\n if (transform.extrusionZ === -1) {\n a = -sx * cos(angle)\n b = sx * sin(angle)\n c = sy * sin(angle)\n d = sy * cos(angle)\n e = -tx\n f = ty\n } else {\n a = sx * cos(angle)\n b = sx * sin(angle)\n c = -sy * sin(angle)\n d = sy * cos(angle)\n e = tx\n f = ty\n }\n return [a, b, c, d, e, f]\n })\n\n // Only transform the bounding box is it is valid (i.e. not Infinity)\n let transformedBBox = new Box2()\n if (bbox.valid) {\n let bboxPoints = [\n { x: bbox.min.x, y: bbox.min.y },\n { x: bbox.max.x, y: bbox.min.y },\n { x: bbox.max.x, y: bbox.max.y },\n { x: bbox.min.x, y: bbox.max.y },\n ]\n for (const [a, b, c, d, e, f] of matrices) {\n bboxPoints = bboxPoints.map((point) => ({\n x: point.x * a + point.y * c + e,\n y: point.x * b + point.y * d + f,\n }))\n }\n transformedBBox = bboxPoints.reduce((acc, point) => {\n return acc.expandByPoint(point)\n }, new Box2())\n }\n\n matrices.reverse()\n for (const [a, b, c, d, e, f] of matrices) {\n transformedElement += `<g transform=\"matrix(${a} ${b} ${c} ${d} ${e} ${f})\">`\n }\n transformedElement += element\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n for (const _ of matrices) {\n transformedElement += '</g>'\n }\n\n return { bbox: transformedBBox, element: transformedElement }\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY;AAQN,SAAR,+BACL,MACA,SACA,YACiB;AACjB,MAAI,qBAAqB;AACzB,QAAM,WAAW,WAAW,IAAI,CAAC,cAAc;AAE7C,UAAM,KAAK,UAAU,KAAK;AAC1B,UAAM,KAAK,UAAU,KAAK;AAC1B,UAAM,KAAK,UAAU,UAAU;AAC/B,UAAM,KAAK,UAAU,UAAU;AAC/B,UAAM,SAAU,UAAU,YAAY,KAAK,MAAO,KAAK;AACvD,UAAM,EAAE,KAAK,IAAI,IAAI;AACrB,QAAI,GAAG,GAAG,GAAG,GAAG,GAAG;AAEnB,QAAI,UAAU,eAAe,IAAI;AAC/B,UAAI,CAAC,KAAK,IAAI,KAAK;AACnB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,CAAC;AACL,UAAI;AAAA,IACN,OAAO;AACL,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI,CAAC,KAAK,IAAI,KAAK;AACnB,UAAI,KAAK,IAAI,KAAK;AAClB,UAAI;AACJ,UAAI;AAAA,IACN;AACA,WAAO,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAAA,EAC1B,CAAC;AAGD,MAAI,kBAAkB,IAAI,KAAK;AAC/B,MAAI,KAAK,OAAO;AACd,QAAI,aAAa;AAAA,MACf,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,KAAK,IAAI,EAAE;AAAA,MAC/B,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,KAAK,IAAI,EAAE;AAAA,MAC/B,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,KAAK,IAAI,EAAE;AAAA,MAC/B,EAAE,GAAG,KAAK,IAAI,GAAG,GAAG,KAAK,IAAI,EAAE;AAAA,IACjC;AACA,eAAW,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,KAAK,UAAU;AACzC,mBAAa,WAAW,IAAI,CAAC,WAAW;AAAA,QACtC,GAAG,MAAM,IAAI,IAAI,MAAM,IAAI,IAAI;AAAA,QAC/B,GAAG,MAAM,IAAI,IAAI,MAAM,IAAI,IAAI;AAAA,MACjC,EAAE;AAAA,IACJ;AACA,sBAAkB,WAAW,OAAO,CAAC,KAAK,UAAU;AAClD,aAAO,IAAI,cAAc,KAAK;AAAA,IAChC,GAAG,IAAI,KAAK,CAAC;AAAA,EACf;AAEA,WAAS,QAAQ;AACjB,aAAW,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,KAAK,UAAU;AACzC,0BAAsB,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAAA,EAC1E;AACA,wBAAsB;AAEtB,aAAW,KAAK,UAAU;AACxB,0BAAsB;AAAA,EACxB;AAEA,SAAO,EAAE,MAAM,iBAAiB,SAAS,mBAAmB;AAC9D;",
6
+ "names": []
7
+ }