From f30b52bf0c09a8d4d067670efac9bfab938e2db1 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Wed, 6 Oct 2021 10:54:02 +0100 Subject: [PATCH] Fix short line bugs. --- packages/dev/package.json | 4 +- packages/dev/src/app.tsx | 1 - packages/dev/src/state/corners.json | 2212 ++++++++++++++++ packages/dev/src/state/excalidraw.json | 679 +++++ packages/dev/src/state/shapes/draw.tsx | 48 +- packages/dev/src/state/state.ts | 19 - packages/perfect-freehand/CHANGELOG.md | 4 + .../src/getStrokeOutlinePoints.ts | 50 +- .../perfect-freehand/src/getStrokePoints.ts | 13 +- .../test/__snapshots__/getStroke.spec.ts.snap | 2308 +++++++++++------ .../getStrokeOutlinePoints.spec.ts.snap | 632 +++-- .../getStrokePoints.spec.ts.snap | 45 +- yarn.lock | 54 +- 13 files changed, 5006 insertions(+), 1063 deletions(-) create mode 100644 packages/dev/src/state/corners.json create mode 100644 packages/dev/src/state/excalidraw.json diff --git a/packages/dev/package.json b/packages/dev/package.json index cb80daf..bdaf148 100644 --- a/packages/dev/package.json +++ b/packages/dev/package.json @@ -33,9 +33,9 @@ "@radix-ui/react-icons": "^1.0.3", "@radix-ui/react-label": "^0.1.0", "@radix-ui/react-slider": "^0.1.0", - "@tldraw/core": "^0.0.94", + "@tldraw/core": "^0.0.107", "@tldraw/intersect": "^0.0.93", - "@tldraw/vec": "^0.0.93", + "@tldraw/vec": "^0.0.107", "perfect-freehand": "^1.0.14", "react": "^17.0.2", "react-dom": "^17.0.2", diff --git a/packages/dev/src/app.tsx b/packages/dev/src/app.tsx index 082aca1..8db13ba 100644 --- a/packages/dev/src/app.tsx +++ b/packages/dev/src/app.tsx @@ -2,7 +2,6 @@ import * as React from 'react' import { Editor } from 'components/editor' import { Controls } from 'components/controls' import { Panel } from 'components/panel' -import { AppState, context, initialState } from 'state' import { useKeyboardShortcuts } from 'hooks' function App(): JSX.Element { diff --git a/packages/dev/src/state/corners.json b/packages/dev/src/state/corners.json new file mode 100644 index 0000000..dc53092 --- /dev/null +++ b/packages/dev/src/state/corners.json @@ -0,0 +1,2212 @@ +{ + "corners": [ + [ + 8.49, + 272.75, + 0.5, + 0 + ], + [ + 9.49, + 273.75, + 0.5, + 10 + ], + [ + 7.91, + 273.33, + 0.5, + 18 + ], + [ + 7.91, + 272.65, + 0.5, + 207 + ], + [ + 11.13, + 268.13, + 0.5, + 213 + ], + [ + 15.34, + 263.21, + 0.5, + 215 + ], + [ + 23.12, + 255.43, + 0.5, + 221 + ], + [ + 34.42, + 244.13, + 0.5, + 230 + ], + [ + 46.74, + 233.86, + 0.5, + 237 + ], + [ + 59.72, + 220.88, + 0.5, + 245 + ], + [ + 77.91, + 205.1, + 0.5, + 254 + ], + [ + 95.34, + 187.67, + 0.5, + 262 + ], + [ + 112.77, + 171.48, + 0.5, + 270 + ], + [ + 131.45, + 155.3, + 0.5, + 279 + ], + [ + 137.09, + 148.03, + 0.5, + 287 + ], + [ + 150.72, + 133.26, + 0.5, + 296 + ], + [ + 154.29, + 130.29, + 0.5, + 302 + ], + [ + 162.55, + 121.1, + 0.5, + 312 + ], + [ + 167.47, + 116.18, + 0.5, + 319 + ], + [ + 170.44, + 112.61, + 0.5, + 329 + ], + [ + 172.6, + 109.9, + 0.5, + 334 + ], + [ + 173.74, + 109.14, + 0.5, + 346 + ], + [ + 174.07, + 108.49, + 0.5, + 351 + ], + [ + 174.34, + 108.21, + 0.5, + 364 + ], + [ + 174.62, + 107.93, + 0.5, + 367 + ], + [ + 174.62, + 108.16, + 0.5, + 410 + ], + [ + 173.74, + 109.9, + 0.5, + 416 + ], + [ + 171.83, + 111.81, + 0.5, + 429 + ], + [ + 167.29, + 118.62, + 0.5, + 432 + ], + [ + 160.38, + 126.38, + 0.5, + 446 + ], + [ + 150.65, + 137.08, + 0.5, + 448 + ], + [ + 131.07, + 162.25, + 0.5, + 463 + ], + [ + 123.29, + 173.92, + 0.5, + 465 + ], + [ + 93.7, + 215.69, + 0.5, + 479 + ], + [ + 85.04, + 230.83, + 0.5, + 483 + ], + [ + 65.29, + 262.74, + 0.5, + 496 + ], + [ + 58.86, + 273.76, + 0.5, + 498 + ], + [ + 54.12, + 281.65, + 0.5, + 512 + ], + [ + 45.9, + 295, + 0.5, + 514 + ], + [ + 40.8, + 304.34, + 0.5, + 522 + ], + [ + 38.2, + 309.53, + 0.5, + 530 + ], + [ + 36.12, + 315.79, + 0.5, + 538 + ], + [ + 36.12, + 316.06, + 0.5, + 546 + ], + [ + 40.28, + 314.87, + 0.5, + 555 + ], + [ + 58.47, + 295.37, + 0.5, + 563 + ], + [ + 101.64, + 248.28, + 0.5, + 570 + ], + [ + 144.02, + 195.81, + 0.5, + 579 + ], + [ + 166.81, + 166.94, + 0.5, + 587 + ], + [ + 211.2, + 116.49, + 0.5, + 595 + ], + [ + 255.4, + 66.25, + 0.5, + 603 + ], + [ + 271.59, + 48.81, + 0.5, + 611 + ], + [ + 282.88, + 37.52, + 0.5, + 619 + ], + [ + 289.79, + 29.74, + 0.5, + 628 + ], + [ + 304.56, + 16.11, + 0.5, + 635 + ], + [ + 312.82, + 6.92, + 0.5, + 645 + ], + [ + 321.46, + 0, + 0.5, + 652 + ], + [ + 322.6, + 0, + 0.5, + 662 + ], + [ + 322.6, + 3.25, + 0.5, + 668 + ], + [ + 307.66, + 21.92, + 0.5, + 679 + ], + [ + 284.87, + 50.79, + 0.5, + 684 + ], + [ + 252.54, + 92.09, + 0.5, + 695 + ], + [ + 179.28, + 181.05, + 0.5, + 701 + ], + [ + 158.77, + 208.87, + 0.5, + 710 + ], + [ + 140.45, + 234.24, + 0.5, + 717 + ], + [ + 108.98, + 280.51, + 0.5, + 729 + ], + [ + 100.33, + 295.65, + 0.5, + 733 + ], + [ + 95.14, + 305.16, + 0.5, + 746 + ], + [ + 84.42, + 324.21, + 0.5, + 749 + ], + [ + 77.61, + 336.85, + 0.5, + 762 + ], + [ + 74.84, + 343.08, + 0.5, + 766 + ], + [ + 72.73, + 349.4, + 0.5, + 777 + ], + [ + 72.73, + 350.05, + 0.5, + 782 + ], + [ + 75.16, + 350.05, + 0.5, + 797 + ], + [ + 88.78, + 345.18, + 0.5, + 799 + ], + [ + 107.39, + 330.29, + 0.5, + 811 + ], + [ + 129.94, + 307.74, + 0.5, + 815 + ], + [ + 159.27, + 276.77, + 0.5, + 829 + ], + [ + 191.28, + 243.07, + 0.5, + 831 + ], + [ + 203.77, + 228.3, + 0.5, + 845 + ], + [ + 212.04, + 219.12, + 0.5, + 847 + ], + [ + 217.33, + 213.06, + 0.5, + 859 + ], + [ + 227.06, + 203.33, + 0.5, + 863 + ], + [ + 238.35, + 192.03, + 0.5, + 872 + ], + [ + 240.79, + 191.05, + 0.5, + 880 + ], + [ + 240.79, + 195.15, + 0.5, + 888 + ], + [ + 214.69, + 236.91, + 0.5, + 896 + ], + [ + 182.27, + 288.38, + 0.5, + 904 + ], + [ + 135.2, + 357.87, + 0.5, + 913 + ], + [ + 82.17, + 439.82, + 0.5, + 920 + ], + [ + 60.98, + 477.3, + 0.5, + 929 + ], + [ + 44.87, + 508.05, + 0.5, + 937 + ], + [ + 34.65, + 525.08, + 0.5, + 945 + ], + [ + 29.13, + 536.1, + 0.5, + 953 + ], + [ + 17.93, + 557.27, + 0.5, + 962 + ], + [ + 0, + 596.38, + 0.5, + 969 + ], + [ + 11.810000000000002, + 584.56, + 0.5, + 986 + ], + [ + 85.44, + 480.93, + 0.5, + 995 + ], + [ + 160.3, + 372.8, + 0.5, + 1002 + ], + [ + 204.01, + 307.23, + 0.5, + 1012 + ], + [ + 288.06000000000006, + 188.39000000000004, + 0.5, + 1018 + ], + [ + 318.59000000000003, + 145.29000000000002, + 0.5, + 1028 + ], + [ + 341.38, + 116.42, + 0.5, + 1034 + ], + [ + 353.87, + 100.51, + 0.5, + 1045 + ], + [ + 359.78, + 92.05999999999999, + 0.5, + 1051 + ], + [ + 393.1, + 47.64, + 0.5, + 1062 + ], + [ + 404.99, + 34.66000000000001, + 0.5, + 1067 + ], + [ + 404.99, + 35.790000000000006, + 0.5, + 1079 + ], + [ + 390.09000000000003, + 60.17, + 0.5, + 1083 + ], + [ + 344.19000000000005, + 125.74, + 0.5, + 1096 + ], + [ + 299.47, + 185.37, + 0.5, + 1099 + ], + [ + 251.21000000000004, + 258.89000000000004, + 0.5, + 1112 + ], + [ + 229.16999999999996, + 291.95, + 0.5, + 1115 + ], + [ + 210.85000000000002, + 317.32, + 0.5, + 1128 + ], + [ + 198.94, + 336.37, + 0.5, + 1132 + ], + [ + 190.72000000000003, + 349.72, + 0.5, + 1146 + ], + [ + 175.82, + 374.1, + 0.5, + 1148 + ], + [ + 167.60000000000002, + 387.45, + 0.5, + 1160 + ], + [ + 157.81, + 409.47999999999996, + 0.5, + 1164 + ], + [ + 163.88, + 406.16, + 0.5, + 1181 + ], + [ + 203.31, + 362.98, + 0.5, + 1196 + ], + [ + 226.73000000000002, + 338.08000000000004, + 0.5, + 1198 + ], + [ + 271.13, + 287.63, + 0.5, + 1206 + ], + [ + 318.82000000000005, + 233.72000000000003, + 0.5, + 1213 + ], + [ + 337.78, + 212.04000000000002, + 0.5, + 1226 + ], + [ + 351.40999999999997, + 197.27000000000004, + 0.5, + 1229 + ], + [ + 359.33000000000004, + 188.47000000000003, + 0.5, + 1238 + ], + [ + 375.51, + 171.03000000000003, + 0.5, + 1246 + ], + [ + 385.02, + 160.58000000000004, + 0.5, + 1255 + ], + [ + 399.78, + 146.94, + 0.5, + 1263 + ], + [ + 397.96000000000004, + 155.42000000000002, + 0.5, + 1278 + ], + [ + 379.25, + 184.21000000000004, + 0.5, + 1287 + ], + [ + 356.44000000000005, + 221.69, + 0.5, + 1295 + ], + [ + 326.82000000000005, + 269.81, + 0.5, + 1303 + ], + [ + 294.4, + 319.38, + 0.5, + 1312 + ], + [ + 280.99, + 338.88, + 0.5, + 1320 + ], + [ + 272.78, + 352.24, + 0.5, + 1328 + ], + [ + 267.90999999999997, + 360.34000000000003, + 0.5, + 1336 + ], + [ + 257.69000000000005, + 377.37, + 0.5, + 1345 + ], + [ + 252.82000000000005, + 385.47, + 0.5, + 1352 + ], + [ + 246.98000000000002, + 398.12000000000006, + 0.5, + 1362 + ], + [ + 254.24, + 393.28000000000003, + 0.5, + 1379 + ], + [ + 274.54999999999995, + 372.96000000000004, + 0.5, + 1384 + ], + [ + 302.73, + 344.78000000000003, + 0.5, + 1395 + ], + [ + 316.36, + 330.01, + 0.5, + 1401 + ], + [ + 342.19000000000005, + 302.66, + 0.5, + 1412 + ], + [ + 351.90999999999997, + 291.96000000000004, + 0.5, + 1417 + ], + [ + 370.11, + 272.46000000000004, + 0.5, + 1427 + ], + [ + 374.32000000000005, + 267.54, + 0.5, + 1433 + ], + [ + 382.53, + 258.40000000000003, + 0.5, + 1446 + ], + [ + 386.74, + 253.49, + 0.5, + 1450 + ], + [ + 392.74, + 248.99, + 0.5, + 1463 + ], + [ + 390.21000000000004, + 258.45, + 0.5, + 1479 + ], + [ + 376.66999999999996, + 284.19, + 0.5, + 1482 + ], + [ + 357.77, + 320.40000000000003, + 0.5, + 1496 + ], + [ + 338.34000000000003, + 359.25, + 0.5, + 1498 + ], + [ + 328.81000000000006, + 379.48, + 0.5, + 1512 + ], + [ + 322, + 392.13, + 0.5, + 1514 + ], + [ + 318.87, + 400.72999999999996, + 0.5, + 1529 + ], + [ + 311.68000000000006, + 415.11000000000007, + 0.5, + 1532 + ], + [ + 307.16999999999996, + 425.92, + 0.5, + 1546 + ], + [ + 304.58000000000004, + 436.3, + 0.5, + 1548 + ], + [ + 304.58000000000004, + 437.44, + 0.5, + 1555 + ], + [ + 309.77, + 436.13000000000005, + 0.5, + 1563 + ], + [ + 325.24, + 420.66, + 0.5, + 1572 + ], + [ + 346.38, + 396.7, + 0.5, + 1580 + ], + [ + 358.87, + 380.79, + 0.5, + 1588 + ], + [ + 380.84000000000003, + 354.43, + 0.5, + 1596 + ], + [ + 391.11, + 342.1, + 0.5, + 1604 + ], + [ + 396.78, + 334.81, + 0.5, + 1612 + ], + [ + 409.16999999999996, + 320.15000000000003, + 0.5, + 1621 + ], + [ + 416.09000000000003, + 311.51, + 0.5, + 1629 + ], + [ + 419.97, + 307.63, + 0.5, + 1637 + ], + [ + 426.02, + 302.33000000000004, + 0.5, + 1645 + ], + [ + 426.02, + 307.29, + 0.5, + 1662 + ], + [ + 421.41999999999996, + 319.23, + 0.5, + 1669 + ], + [ + 414.23, + 333.61, + 0.5, + 1679 + ], + [ + 411.20000000000005, + 341.17, + 0.5, + 1686 + ], + [ + 405.03999999999996, + 355.55, + 0.5, + 1696 + ], + [ + 403.85, + 359.71000000000004, + 0.5, + 1702 + ], + [ + 400.82000000000005, + 367.28000000000003, + 0.5, + 1710 + ], + [ + 398.89, + 372.42, + 0.5, + 1719 + ], + [ + 397.90999999999997, + 374.86, + 0.5, + 1728 + ], + [ + 397.90999999999997, + 378.11, + 0.5, + 1734 + ], + [ + 397.90999999999997, + 378.38, + 0.5, + 1745 + ], + [ + 399.65, + 378.38, + 0.5, + 1751 + ], + [ + 403.21000000000004, + 375.40000000000003, + 0.5, + 1763 + ], + [ + 409.24, + 370.13, + 0.5, + 1767 + ], + [ + 417.02, + 362.35, + 0.5, + 1778 + ], + [ + 424.78999999999996, + 355.43, + 0.5, + 1784 + ], + [ + 427.77, + 352.45, + 0.5, + 1795 + ], + [ + 432.65999999999997, + 347.55, + 0.5, + 1799 + ], + [ + 436.23, + 344.58000000000004, + 0.5, + 1812 + ], + [ + 438.39, + 341.87, + 0.5, + 1816 + ], + [ + 440.33000000000004, + 340.42, + 0.5, + 1828 + ], + [ + 440.98, + 340.09000000000003, + 0.5, + 1832 + ], + [ + 441.63, + 340.09000000000003, + 0.5, + 1843 + ], + [ + 441.9, + 340.09000000000003, + 0.5, + 1848 + ], + [ + 441.9, + 345.28000000000003, + 0.5, + 1862 + ], + [ + 441.9, + 354.19, + 0.5, + 1865 + ], + [ + 438.02, + 367.78000000000003, + 0.5, + 1878 + ], + [ + 433.90999999999997, + 383.19, + 0.5, + 1881 + ], + [ + 431.68000000000006, + 390.6, + 0.5, + 1895 + ], + [ + 428.76, + 404.21999999999997, + 0.5, + 1898 + ], + [ + 427.46000000000004, + 409.40000000000003, + 0.5, + 1912 + ], + [ + 426.65, + 418.31, + 0.5, + 1914 + ], + [ + 426.01, + 423.41, + 0.5, + 1926 + ], + [ + 426.01, + 430.96999999999997, + 0.5, + 1930 + ], + [ + 426.01, + 432.11000000000007, + 0.5, + 1937 + ], + [ + 427.13, + 432.11000000000007, + 0.5, + 1946 + ], + [ + 433.45000000000005, + 432.11000000000007, + 0.5, + 1955 + ], + [ + 441.56000000000006, + 428.06, + 0.5, + 1963 + ], + [ + 452.23, + 419.32, + 0.5, + 1971 + ], + [ + 465.21000000000004, + 407.42, + 0.5, + 1979 + ], + [ + 478.84000000000003, + 392.65000000000003, + 0.5, + 1987 + ], + [ + 494.31000000000006, + 377.17, + 0.5, + 1995 + ], + [ + 500.78999999999996, + 370.69, + 0.5, + 2003 + ], + [ + 513.77, + 358.79, + 0.5, + 2012 + ], + [ + 516.74, + 355.22, + 0.5, + 2019 + ], + [ + 524.52, + 348.3, + 0.5, + 2029 + ], + [ + 529.4300000000001, + 344.09000000000003, + 0.5, + 2036 + ], + [ + 532.11, + 341.94, + 0.5, + 2045 + ], + [ + 533.84, + 341.07, + 0.5, + 2052 + ], + [ + 534.49, + 341.07, + 0.5, + 2062 + ], + [ + 534.77, + 341.07, + 0.5, + 2069 + ], + [ + 534.77, + 348.63, + 0.5, + 2079 + ], + [ + 532.01, + 360.57, + 0.5, + 2084 + ], + [ + 526.91, + 375.87, + 0.5, + 2096 + ], + [ + 520.09, + 394.05, + 0.5, + 2101 + ], + [ + 517.87, + 401.45, + 0.5, + 2114 + ], + [ + 513.76, + 416.84999999999997, + 0.5, + 2118 + ], + [ + 512.57, + 421.02000000000004, + 0.5, + 2129 + ], + [ + 511.04999999999995, + 428.58, + 0.5, + 2133 + ], + [ + 509.76, + 433.72999999999996, + 0.5, + 2145 + ], + [ + 509.76, + 441.3, + 0.5, + 2150 + ], + [ + 509.76, + 441.95, + 0.5, + 2163 + ], + [ + 511.5, + 441.95, + 0.5, + 2166 + ], + [ + 517.74, + 441.95, + 0.5, + 2179 + ], + [ + 529.42, + 434.16, + 0.5, + 2182 + ], + [ + 541.74, + 423.89000000000004, + 0.5, + 2196 + ], + [ + 557.64, + 412.53000000000003, + 0.5, + 2198 + ], + [ + 563.69, + 407.22999999999996, + 0.5, + 2212 + ], + [ + 576.02, + 396.96, + 0.5, + 2215 + ], + [ + 579.58, + 394.58000000000004, + 0.5, + 2229 + ], + [ + 586.88, + 388.90000000000003, + 0.5, + 2232 + ], + [ + 591.42, + 385.65000000000003, + 0.5, + 2244 + ], + [ + 594.63, + 384.05, + 0.5, + 2248 + ], + [ + 597.87, + 383.5, + 0.5, + 2262 + ], + [ + 598.53, + 383.5, + 0.5, + 2265 + ], + [ + 598.53, + 387.65000000000003, + 0.5, + 2276 + ], + [ + 598.53, + 399.58, + 0.5, + 2280 + ], + [ + 595.35, + 416.49000000000007, + 0.5, + 2288 + ], + [ + 592.76, + 426.87000000000006, + 0.5, + 2296 + ], + [ + 588.65, + 442.27000000000004, + 0.5, + 2304 + ], + [ + 587.24, + 448.59, + 0.5, + 2313 + ], + [ + 584.65, + 458.96, + 0.5, + 2321 + ], + [ + 583.13, + 466.53000000000003, + 0.5, + 2329 + ], + [ + 583.13, + 476.90000000000003, + 0.5, + 2337 + ], + [ + 583.13, + 478.04, + 0.5, + 2346 + ], + [ + 584.28, + 478.42, + 0.5, + 2353 + ], + [ + 590.6, + 478.42, + 0.5, + 2361 + ], + [ + 602.75, + 469.3, + 0.5, + 2370 + ], + [ + 617.51, + 455.67, + 0.5, + 2378 + ], + [ + 634.94, + 438.22999999999996, + 0.5, + 2386 + ], + [ + 654.44, + 420.03000000000003, + 0.5, + 2395 + ], + [ + 662.22, + 413.12000000000006, + 0.5, + 2402 + ], + [ + 668.27, + 408.58, + 0.5, + 2412 + ], + [ + 676.91, + 401.66, + 0.5, + 2419 + ], + [ + 682.96, + 396.36000000000007, + 0.5, + 2426 + ], + [ + 692.47, + 392.04, + 0.5, + 2435 + ], + [ + 694.2, + 392.04, + 0.5, + 2445 + ], + [ + 695.94, + 392.04, + 0.5, + 2451 + ], + [ + 696.67, + 399.45, + 0.5, + 2462 + ], + [ + 696.67, + 409.82, + 0.5, + 2467 + ], + [ + 696.67, + 416.14000000000004, + 0.5, + 2479 + ], + [ + 695.8100000000001, + 426.51000000000005, + 0.5, + 2483 + ], + [ + 693.23, + 436.8, + 0.5, + 2495 + ], + [ + 692.63, + 440.96, + 0.5, + 2500 + ], + [ + 691.9300000000001, + 447.28000000000003, + 0.5, + 2511 + ], + [ + 691.9300000000001, + 452.46999999999997, + 0.5, + 2516 + ], + [ + 691.9300000000001, + 457.65000000000003, + 0.5, + 2529 + ], + [ + 691.9300000000001, + 458.8, + 0.5, + 2532 + ], + [ + 695.15, + 459.33, + 0.5, + 2545 + ], + [ + 702.72, + 459.33, + 0.5, + 2548 + ], + [ + 711.63, + 458.52000000000004, + 0.5, + 2561 + ], + [ + 724.98, + 450.3, + 0.5, + 2565 + ], + [ + 740.1200000000001, + 441.65000000000003, + 0.5, + 2576 + ], + [ + 746.0799999999999, + 436.43, + 0.5, + 2581 + ], + [ + 759.4300000000001, + 427.19, + 0.5, + 2595 + ], + [ + 769.53, + 419.83, + 0.5, + 2598 + ], + [ + 772.23, + 417.67, + 0.5, + 2611 + ], + [ + 777.8499999999999, + 414.15000000000003, + 0.5, + 2614 + ], + [ + 781.4200000000001, + 411.17, + 0.5, + 2622 + ], + [ + 783.8499999999999, + 410.2, + 0.5, + 2630 + ], + [ + 786.28, + 409.71, + 0.5, + 2638 + ], + [ + 786.55, + 409.71, + 0.5, + 2646 + ], + [ + 787.03, + 412.09999999999997, + 0.5, + 2655 + ], + [ + 787.6200000000001, + 416.27000000000004, + 0.5, + 2662 + ], + [ + 788.3199999999999, + 422.59, + 0.5, + 2671 + ], + [ + 789.02, + 428.91, + 0.5, + 2679 + ], + [ + 789.51, + 431.34999999999997, + 0.5, + 2687 + ], + [ + 792.0999999999999, + 441.71999999999997, + 0.5, + 2695 + ], + [ + 793.8399999999999, + 445.8, + 0.5, + 2704 + ], + [ + 795.3, + 447.74000000000007, + 0.5, + 2712 + ], + [ + 799.0799999999999, + 454.55, + 0.5, + 2720 + ], + [ + 801.03, + 456.01000000000005, + 0.5, + 2728 + ], + [ + 805.95, + 460.21999999999997, + 0.5, + 2738 + ], + [ + 809.1700000000001, + 461.83, + 0.5, + 2745 + ], + [ + 812.74, + 464.21, + 0.5, + 2752 + ], + [ + 815.98, + 465.29, + 0.5, + 2762 + ], + [ + 820.1500000000001, + 466.47999999999996, + 0.5, + 2768 + ], + [ + 824.3, + 467.07, + 0.5, + 2778 + ], + [ + 828.46, + 467.66, + 0.5, + 2785 + ], + [ + 832.6300000000001, + 467.66, + 0.5, + 2795 + ], + [ + 837.81, + 467.66, + 0.5, + 2801 + ], + [ + 843.8700000000001, + 463.12000000000006, + 0.5, + 2812 + ], + [ + 849.9200000000001, + 458.58, + 0.5, + 2817 + ], + [ + 862.8900000000001, + 446.69, + 0.5, + 2828 + ], + [ + 866.1300000000001, + 442.14000000000004, + 0.5, + 2834 + ], + [ + 872.8700000000001, + 433.71, + 0.5, + 2845 + ], + [ + 879.79, + 425.93, + 0.5, + 2850 + ], + [ + 892.8800000000001, + 408.07, + 0.5, + 2862 + ], + [ + 895.8499999999999, + 404.50000000000006, + 0.5, + 2866 + ], + [ + 898.02, + 401.8, + 0.5, + 2878 + ], + [ + 903.31, + 395.74, + 0.5, + 2882 + ], + [ + 906.28, + 392.17, + 0.5, + 2896 + ], + [ + 908.44, + 389.47, + 0.5, + 2899 + ], + [ + 909.74, + 388.17, + 0.5, + 2912 + ], + [ + 910.3900000000001, + 387.51, + 0.5, + 2916 + ], + [ + 911.04, + 387.18, + 0.5, + 2929 + ], + [ + 911.04, + 387.94, + 0.5, + 2964 + ], + [ + 911.04, + 391.19, + 0.5, + 2977 + ], + [ + 911.04, + 395.35, + 0.5, + 2980 + ], + [ + 908.1300000000001, + 408.92, + 0.5, + 2988 + ], + [ + 907.69, + 410.65000000000003, + 0.5, + 2996 + ], + [ + 904.79, + 424.21, + 0.5, + 3005 + ], + [ + 904.3, + 426.65000000000003, + 0.5, + 3012 + ], + [ + 904.3, + 427.3, + 0.5, + 3022 + ], + [ + 904.3, + 430.55, + 0.5, + 3029 + ], + [ + 904.3, + 433.8, + 0.5, + 3037 + ], + [ + 906.03, + 434.22999999999996, + 0.5, + 3045 + ], + [ + 906.03, + 433.75000000000006, + 0.5, + 3094 + ], + [ + 912.45, + 422.74000000000007, + 0.5, + 3102 + ], + [ + 921.7, + 409.38000000000005, + 0.5, + 3111 + ], + [ + 929.48, + 397.71, + 0.5, + 3119 + ], + [ + 935.6400000000001, + 383.32, + 0.5, + 3130 + ], + [ + 940.5, + 369.7, + 0.5, + 3135 + ], + [ + 944.1700000000001, + 357.76, + 0.5, + 3145 + ], + [ + 945.8700000000001, + 347.57, + 0.5, + 3151 + ], + [ + 946.73, + 337.2, + 0.5, + 3162 + ], + [ + 947.9200000000001, + 315.77000000000004, + 0.5, + 3167 + ], + [ + 948.5699999999999, + 310.58000000000004, + 0.5, + 3179 + ], + [ + 949.3800000000001, + 301.66, + 0.5, + 3183 + ], + [ + 949.3800000000001, + 292.75, + 0.5, + 3196 + ], + [ + 949.3800000000001, + 289.5, + 0.5, + 3200 + ], + [ + 949.3800000000001, + 283.17, + 0.5, + 3212 + ], + [ + 949.3800000000001, + 279.01, + 0.5, + 3216 + ], + [ + 949.3800000000001, + 268.63, + 0.5, + 3229 + ], + [ + 949.3800000000001, + 266.89000000000004, + 0.5, + 3232 + ], + [ + 949.8599999999999, + 264.45, + 0.5, + 3246 + ], + [ + 949.8599999999999, + 262.71000000000004, + 0.5, + 3249 + ], + [ + 949.8599999999999, + 260.27000000000004, + 0.5, + 3261 + ], + [ + 949.8599999999999, + 259.99, + 0.5, + 3264 + ], + [ + 949.8599999999999, + 259.44, + 0.5, + 3281 + ], + [ + 949.8599999999999, + 259.17, + 0.5, + 3295 + ], + [ + 949.8599999999999, + 258.89000000000004, + 0.5, + 3299 + ], + [ + 949.8599999999999, + 259.12, + 0.5, + 3347 + ], + [ + 949.8599999999999, + 259.38, + 0.5, + 3355 + ], + [ + 949.8599999999999, + 259.66, + 0.5, + 3363 + ] + ] +} \ No newline at end of file diff --git a/packages/dev/src/state/excalidraw.json b/packages/dev/src/state/excalidraw.json new file mode 100644 index 0000000..0543556 --- /dev/null +++ b/packages/dev/src/state/excalidraw.json @@ -0,0 +1,679 @@ +{ + "type": "excalidraw", + "version": 2, + "source": "https://excalidraw.com", + "elements": [ + { + "type": "rectangle", + "version": 165, + "versionNonce": 1437958102, + "isDeleted": false, + "id": "Ha4HSXfRj44CKv2p3Rj7I", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 202.17364760843054, + "y": 639.5270876466532, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 112.85714285714278, + "height": 94.28571428571446, + "seed": 114976664, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "-EHziqjGHk4B1NuZHwn03" + ] + }, + { + "type": "rectangle", + "version": 82, + "versionNonce": 709070986, + "isDeleted": false, + "id": "8071Py40CDL4zmvT3CWCx", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 433.602219037002, + "y": 666.6699447895103, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 112.85714285714278, + "height": 71.42857142857156, + "seed": 1283029736, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "dwe3nNsrVJUtqhWKpk2nX" + ] + }, + { + "type": "freedraw", + "version": 131, + "versionNonce": 971183382, + "isDeleted": false, + "id": "2JHVHq5EaNVmLBkR9pqjK", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 735.9285714285713, + "y": 1201.5714285714284, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 302, + "height": 70, + "seed": 2069284399, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "points": [ + [ + 0, + 0 + ], + [ + -302, + -70 + ] + ], + "lastCommittedPoint": null, + "simulatePressure": false, + "pressures": [ + 0, + 0.07999999821186066 + ] + }, + { + "type": "freedraw", + "version": 138, + "versionNonce": 424996682, + "isDeleted": false, + "id": "g99sDQcNlf8-GgLnumbNB", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 275.2792207792206, + "y": 617.9155844155848, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 66.36363636363637, + "height": 209.09090909090912, + "seed": 106595169, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "points": [ + [ + 0, + 0 + ], + [ + 6.363636363636374, + -7.272727272727252 + ], + [ + 9.090909090909122, + -12.727272727272748 + ], + [ + -57.27272727272725, + 196.36363636363637 + ] + ], + "lastCommittedPoint": null, + "simulatePressure": false, + "pressures": [ + 0, + 0, + 0, + 0 + ] + }, + { + "type": "freedraw", + "version": 100, + "versionNonce": 103547478, + "isDeleted": false, + "id": "9wzgTRRnUxWPfXOgXr5DX", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 492.5843016632492, + "y": 1106.4079516974261, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 102.63157894736838, + "height": 211.40350877192986, + "seed": 1072775183, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "points": [ + [ + 0, + 0 + ], + [ + -102.63157894736838, + 211.40350877192986 + ] + ], + "lastCommittedPoint": null, + "simulatePressure": false, + "pressures": [ + 0, + 0 + ] + }, + { + "type": "freedraw", + "version": 337, + "versionNonce": 1145861642, + "isDeleted": false, + "id": "xZQ3jUF5qYSqzH3M0fkDp", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 286.8242019670836, + "y": 1124.9102638154604, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 168.98734177215186, + "height": 70.8860759493673, + "seed": 1116285377, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "points": [ + [ + 0, + 0 + ], + [ + -168.98734177215186, + -70.8860759493673 + ] + ], + "lastCommittedPoint": null, + "simulatePressure": false, + "pressures": [ + 0, + 0.07999999821186066 + ] + }, + { + "type": "freedraw", + "version": 220, + "versionNonce": 1298483094, + "isDeleted": false, + "id": "MmgnGuXoRWGIteFP3Bsmp", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 604.8606641324292, + "y": 1320.7823529254492, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 178.48101265822777, + "height": 73.41772151898749, + "seed": 1174808833, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "points": [ + [ + 0, + 0 + ], + [ + -178.48101265822777, + -73.41772151898749 + ] + ], + "lastCommittedPoint": null, + "simulatePressure": false, + "pressures": [ + 0, + 0.07999999821186066 + ] + }, + { + "type": "freedraw", + "version": 154, + "versionNonce": 472196298, + "isDeleted": false, + "id": "lK97Vc4zX-NPkVUq_bjDR", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 457.9838763006346, + "y": 1247.7911080505105, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 156.96202531645565, + "height": 48.7341772151899, + "seed": 760161519, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "points": [ + [ + 0, + 0 + ], + [ + -156.96202531645565, + -48.7341772151899 + ] + ], + "lastCommittedPoint": null, + "simulatePressure": false, + "pressures": [ + 0, + 0.07999999821186066 + ] + }, + { + "type": "freedraw", + "version": 487, + "versionNonce": 445895062, + "isDeleted": false, + "id": "0GsgMd4useUUTrlidzxo5", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 549.0159772321532, + "y": 749.1012883038112, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 141.77215189873408, + "height": 84.17721518987355, + "seed": 1481097153, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "points": [ + [ + 0, + 0 + ], + [ + 5.696202531645554, + -5.6962025316456675 + ], + [ + 6.962025316455652, + -5.6962025316456675 + ], + [ + 7.5949367088607005, + -5.6962025316456675 + ], + [ + -134.17721518987338, + -84.17721518987355 + ] + ], + "lastCommittedPoint": null, + "simulatePressure": false, + "pressures": [ + 0, + 0, + 0, + 0, + 0.07999999821186066 + ] + }, + { + "type": "freedraw", + "version": 101, + "versionNonce": 981072778, + "isDeleted": false, + "id": "wyGBWwVfwh9aLxV31vThB", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 218.01242236024854, + "y": 1288.2608695652175, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 73.29192546583846, + "height": 152.17391304347825, + "seed": 1973316175, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "points": [ + [ + 0, + 0 + ], + [ + 73.29192546583846, + -152.17391304347825 + ] + ], + "lastCommittedPoint": null, + "simulatePressure": false, + "pressures": [ + 0, + 0 + ] + }, + { + "type": "arrow", + "version": 36, + "versionNonce": 1054661142, + "isDeleted": false, + "id": "-EHziqjGHk4B1NuZHwn03", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 53.60221903700187, + "y": 772.3842305037962, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 144.28571428571433, + "height": 70, + "seed": 1939710696, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "startBinding": null, + "endBinding": { + "elementId": "Ha4HSXfRj44CKv2p3Rj7I", + "focus": 0.18439783619625968, + "gap": 4.285714285714334 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + 144.28571428571433, + -70 + ] + ] + }, + { + "type": "arrow", + "version": 48, + "versionNonce": 1300625994, + "isDeleted": false, + "id": "dwe3nNsrVJUtqhWKpk2nX", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 55.03079046557332, + "y": 772.3842305037962, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 370.8053915248326, + "height": 30.658310758948005, + "seed": 1450736792, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "startBinding": null, + "endBinding": { + "elementId": "8071Py40CDL4zmvT3CWCx", + "focus": -0.8428482198625827, + "gap": 8.571428571428442 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + 370.8053915248326, + -30.658310758948005 + ] + ] + }, + { + "type": "text", + "version": 89, + "versionNonce": 832907094, + "isDeleted": false, + "id": "pjDUyZCfkGTg9pUjp2yld", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": -144.96920953442674, + "y": 757.0270876466533, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 486, + "height": 105, + "seed": 778801896, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "fontSize": 28, + "fontFamily": 1, + "text": "hits are not\nregistered when clicking on the lines\nin these areas", + "baseline": 95, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "rectangle", + "version": 95, + "versionNonce": 69476618, + "isDeleted": false, + "id": "mxulMZ1UspGrmJ3KAAOcj", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 72.17364760843031, + "y": 1035.2413733609392, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 755.7142857142857, + "height": 324.28571428571433, + "seed": 1544799464, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [] + }, + { + "type": "text", + "version": 168, + "versionNonce": 1483852950, + "isDeleted": false, + "id": "nDVtZAb_udCraafndCv2z", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 205.03079046557343, + "y": 1394.1699447895103, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 563, + "height": 70, + "seed": 1386975128, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "fontSize": 28, + "fontFamily": 1, + "text": "all these \"points\" are actually lines.\nSelect them to see their bounding boxes.", + "baseline": 60, + "textAlign": "left", + "verticalAlign": "top" + }, + { + "type": "arrow", + "version": 80, + "versionNonce": 2043637706, + "isDeleted": false, + "id": "Z0n4R_iIfG53FrM11qr_B", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 679.3165047512875, + "y": 587.059592198745, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 385.71428571428567, + "height": 15.324638305051167, + "seed": 163460760, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "startBinding": { + "elementId": "nTqjnH6DHFK71QBkXyb4D", + "focus": 0.32284915686334503, + "gap": 9.999999999999773 + }, + "endBinding": null, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + -385.71428571428567, + 15.324638305051167 + ] + ] + }, + { + "type": "arrow", + "version": 67, + "versionNonce": 1626851798, + "isDeleted": false, + "id": "JdK63HbC67f4clxAgYQB8", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 679.3165047512875, + "y": 598.8788619447587, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 112.85714285714278, + "height": 136.36251141618027, + "seed": 1581204376, + "groupIds": [], + "strokeSharpness": "round", + "boundElementIds": [], + "startBinding": { + "elementId": "nTqjnH6DHFK71QBkXyb4D", + "focus": 0.8806145565415848, + "gap": 9.999999999999773 + }, + "endBinding": null, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + -112.85714285714278, + 136.36251141618027 + ] + ] + }, + { + "type": "text", + "version": 115, + "versionNonce": 581101194, + "isDeleted": false, + "id": "nTqjnH6DHFK71QBkXyb4D", + "fillStyle": "solid", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 689.3165047512873, + "y": 558.4556590752247, + "strokeColor": "#c92a2a", + "backgroundColor": "transparent", + "width": 335, + "height": 70, + "seed": 783218152, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "JdK63HbC67f4clxAgYQB8", + "Z0n4R_iIfG53FrM11qr_B" + ], + "fontSize": 28, + "fontFamily": 1, + "text": "you can select them\nby clicking on these ends", + "baseline": 60, + "textAlign": "left", + "verticalAlign": "top" + } + ], + "appState": { + "gridSize": null, + "viewBackgroundColor": "#ffffff" + } +} \ No newline at end of file diff --git a/packages/dev/src/state/shapes/draw.tsx b/packages/dev/src/state/shapes/draw.tsx index c21b9cc..a9cb82e 100644 --- a/packages/dev/src/state/shapes/draw.tsx +++ b/packages/dev/src/state/shapes/draw.tsx @@ -74,27 +74,27 @@ export const Draw = new ShapeUtil(() => ({ const simulatePressure = shape.points[2]?.[2] === 0.5 - const drawPathData = getSvgPathFromStroke( - getStroke(shape.points, { - size, - thinning, - streamline, - easing: EASINGS[easing], - smoothing, - start: { - taper: taperStart, - cap: capStart, - easing: EASINGS[easingStart], - }, - end: { taper: taperEnd, cap: capEnd, easing: EASINGS[easingEnd] }, - simulatePressure, - last: isDone, - }) - ) + const outlinePoints = getStroke(shape.points, { + size, + thinning, + streamline, + easing: EASINGS[easing], + smoothing, + start: { + taper: taperStart, + cap: capStart, + easing: EASINGS[easingStart], + }, + end: { taper: taperEnd, cap: capEnd, easing: EASINGS[easingEnd] }, + simulatePressure, + last: isDone, + }) + + const drawPathData = getSvgPathFromStroke(outlinePoints) return ( - {strokeWidth && ( + {strokeWidth ? ( (() => ({ strokeLinecap="round" pointerEvents="all" /> - )} + ) : null} { (() => ({ }, getBounds(shape: DrawShape): TLBounds { - return Utils.translateBounds( + const bounds = Utils.translateBounds( Utils.getFromCache(pointsBoundsCache, shape.points, () => Utils.getBoundsFromPoints(shape.points) ), shape.point ) - }, - shouldRender(prev: DrawShape, next: DrawShape): boolean { - return true - // return next.points !== prev.points || next.style !== prev.style + return bounds }, hitTestBounds(shape: DrawShape, brushBounds: TLBounds): boolean { @@ -218,7 +215,8 @@ function getSvgPathFromStroke(points: number[][]): string { return points .reduce( (acc, point, i, arr) => { - if (i === points.length - 1) acc.push(point, Vec.med(point, arr[0])) + if (i === points.length - 1) + acc.push(point, Vec.med(point, arr[0]), 'Z') else acc.push(point, Vec.med(point, arr[i + 1])) return acc }, diff --git a/packages/dev/src/state/state.ts b/packages/dev/src/state/state.ts index be09ab2..309d12f 100644 --- a/packages/dev/src/state/state.ts +++ b/packages/dev/src/state/state.ts @@ -84,23 +84,6 @@ export class AppState extends StateManager { this.addShape({ id: 'sample', points: sample }) this.centerShape('sample') } - - // const result = getStroke(sample, { - // size: -0.1795946853235364, - // thinning: 0.12744471128098667, - // streamline: 0.48121243389323354, - // smoothing: 0.4285292432177812, - // simulatePressure: true, - // last: false, - // start: { - // cap: true, - // taper: 0, - // }, - // end: { - // cap: false, - // taper: 49.22944081481546, - // }, - // }) } cleanup = (state: State) => { @@ -369,8 +352,6 @@ export class AppState extends StateManager { ...shapeUtils.draw.onSessionComplete(shape), } - if (this.log) console.log(shape.points) - return this.setState({ before: { appState: { diff --git a/packages/perfect-freehand/CHANGELOG.md b/packages/perfect-freehand/CHANGELOG.md index 0c2027b..da71744 100644 --- a/packages/perfect-freehand/CHANGELOG.md +++ b/packages/perfect-freehand/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.15 + +- Bug fixes related to very short lines. + ## 1.0.14 - Updates README and documentation. diff --git a/packages/perfect-freehand/src/getStrokeOutlinePoints.ts b/packages/perfect-freehand/src/getStrokeOutlinePoints.ts index 6678100..4ca9f82 100644 --- a/packages/perfect-freehand/src/getStrokeOutlinePoints.ts +++ b/packages/perfect-freehand/src/getStrokeOutlinePoints.ts @@ -7,6 +7,7 @@ import { lrp, med, mul, + neg, per, prj, rotAround, @@ -64,7 +65,9 @@ export function getStrokeOutlinePoints( } = end // We can't do anything with an empty array or a stroke with negative size. - if (points.length === 0 || size <= 0) return [] + if (points.length === 0 || size <= 0) { + return [] + } // The total length of the line const totalLength = points[points.length - 1].runningLength @@ -125,12 +128,14 @@ export function getStrokeOutlinePoints( skipping the first and last pointsm, which will get caps later on. */ - for (let i = 0; i < points.length - 1; i++) { + for (let i = 0; i < points.length; i++) { let { pressure } = points[i] const { point, vector, distance, runningLength } = points[i] // Removes noise from the end of the line - if (totalLength - runningLength < 3) continue + if (i < points.length - 1 && totalLength - runningLength < 3) { + continue + } /* Calculate the radius @@ -184,6 +189,14 @@ export function getStrokeOutlinePoints( /* Add points to left and right */ + // Handle the last point + if (i === points.length - 1) { + const offset = mul(per(vector), radius) + leftPts.push(sub(point, offset)) + rightPts.push(add(point, offset)) + continue + } + const nextVector = points[i + 1].vector const nextDpr = dpr(vector, nextVector) @@ -231,14 +244,14 @@ export function getStrokeOutlinePoints( tl = sub(point, offset) - if (i === 0 || dist2(pl, tl) > minDistance) { + if (i <= 1 || dist2(pl, tl) > minDistance) { leftPts.push(tl) pl = tl } tr = add(point, offset) - if (i === 0 || dist2(pr, tr) > minDistance) { + if (i <= 1 || dist2(pr, tr) > minDistance) { rightPts.push(tr) pr = tr } @@ -263,8 +276,6 @@ export function getStrokeOutlinePoints( ? points[points.length - 1].point.slice(0, 2) : add(points[0].point, [1, 1]) - const isVeryShort = leftPts.length <= 1 || rightPts.length <= 1 - const startCap: number[][] = [] const endCap: number[][] = [] @@ -278,20 +289,17 @@ export function getStrokeOutlinePoints( we can just return those points. */ - if (isVeryShort) { + if (points.length === 1) { if (!(taperStart || taperEnd) || isComplete) { const start = prj( firstPoint, uni(per(sub(firstPoint, lastPoint))), -(firstRadius || radius) ) - const dotPts: number[][] = [] - for (let step = 1 / 13, t = step; t <= 1; t += step) { dotPts.push(rotAround(start, firstPoint, FIXED_PI * 2 * t)) } - return dotPts } } else { @@ -304,7 +312,7 @@ export function getStrokeOutlinePoints( Finally remove the first left and right points. :psyduck: */ - if (taperStart || (taperEnd && isVeryShort)) { + if (taperStart || (taperEnd && points.length === 1)) { // The start point is tapered, noop } else if (capStart) { // Draw the round cap - add thirteen points rotating the right point around the start point to the left point @@ -330,30 +338,26 @@ export function getStrokeOutlinePoints( Draw an end cap If the line does not have a tapered end, and unless the line has a tapered - start and the line is very short, draw a cap around the last point. Finally, + start and the line is very short, draw a cap around the last point. Finally, remove the last left and right points. Otherwise, add the last point. Note - that This cap is a full-turn-and-a-half: this prevents incorrect caps on + that This cap is a full-turn-and-a-half: this prevents incorrect caps on sharp end turns. */ - // The mid point between the last left and right points - const mid = med(leftPts[leftPts.length - 1], rightPts[rightPts.length - 1]) - - // The direction vector from the mid point to the last point - const direction = per(uni(sub(lastPoint, mid))) + const direction = per(neg(points[points.length - 1].vector)) - if (taperEnd || (taperStart && isVeryShort)) { + if (taperEnd || (taperStart && points.length === 1)) { // Tapered end - push the last point to the line endCap.push(lastPoint) } else if (capEnd) { // Draw the round end cap const start = prj(lastPoint, direction, radius) - for (let step = 1 / 29, t = 0; t <= 1; t += step) { - const pt = rotAround(start, lastPoint, FIXED_PI * 3 * t) - endCap.push(pt) + for (let step = 1 / 29, t = step; t < 1; t += step) { + endCap.push(rotAround(start, lastPoint, FIXED_PI * 3 * t)) } } else { // Draw the flat end cap + endCap.push( add(lastPoint, mul(direction, radius)), add(lastPoint, mul(direction, radius * 0.99)), diff --git a/packages/perfect-freehand/src/getStrokePoints.ts b/packages/perfect-freehand/src/getStrokePoints.ts index 52db8f2..d59e244 100644 --- a/packages/perfect-freehand/src/getStrokePoints.ts +++ b/packages/perfect-freehand/src/getStrokePoints.ts @@ -32,6 +32,17 @@ export function getStrokePoints< ? (points as T[]) : (points as K[]).map(({ x, y, pressure = 0.5 }) => [x, y, pressure]) + // Add extra points between the two, to help avoid "dash" lines + // for strokes with tapered start and ends. Don't mutate the + // input array! + if (pts.length === 2) { + const last = pts[1] + pts = pts.slice(0, -1) + for (let i = 1; i < 5; i++) { + pts.push(lrp(pts[0], last, i / 4)) + } + } + // If there's only one point, add another point at a 1pt offset. // Don't mutate the input array! if (pts.length === 1) { @@ -68,7 +79,7 @@ export function getStrokePoints< isComplete && i === max ? // If we're at the last point, and `options.last` is true, // then add the actual input point. - pts[i] + pts[i].slice(0, 2) : // Otherwise, using the t calculated from the streamline // option, interpolate a new point between the previous // point the current point. diff --git a/packages/perfect-freehand/src/test/__snapshots__/getStroke.spec.ts.snap b/packages/perfect-freehand/src/test/__snapshots__/getStroke.spec.ts.snap index d8259ac..b3b989f 100644 --- a/packages/perfect-freehand/src/test/__snapshots__/getStroke.spec.ts.snap +++ b/packages/perfect-freehand/src/test/__snapshots__/getStroke.spec.ts.snap @@ -3,56 +3,180 @@ exports[`getStroke Solves a tricky stroke with only one point. 1`] = ` Array [ Array [ - 465.38736272168285, - 286.36125581709666, + 465.7241672374853, + 286.8458327625147, ], Array [ - 465.40180718008634, - 286.6001426514782, + 465.7880156105495, + 286.93472200847765, ], Array [ - 465.30357750791137, - 286.81837760175847, + 465.8201381692009, + 287.0393453998226, ], Array [ - 465.11517834388104, - 286.965962550219, + 465.817171673069, + 287.14874883985766, ], Array [ - 464.87977236001075, - 287.0090854533852, + 465.779426715082, + 287.25147775953167, ], Array [ - 464.6512915964161, - 286.9378667571979, + 465.71085520230486, + 287.3367764138368, ], Array [ - 464.48208150967906, - 286.7686228250589, + 465.6186365902264, + 287.3957140111507, ], Array [ - 464.4109085110686, - 286.54012782229466, + 465.51242619187457, + 287.4221197694766, ], Array [ - 464.45407849456876, - 286.30473046771306, + 465.4033442639937, + 287.41322899894726, ], Array [ - 464.60170111991016, - 286.1163608244403, + 465.30281171322764, + 287.36997256558413, ], Array [ - 464.81995571176, - 286.01817480121963, + 465.22135432417974, + 287.2968794293789, ], Array [ - 465.05883965247216, - 286.0326670367008, + 465.16750070698595, + 287.201602460987, ], Array [ - 465.2636240941999, - 286.1565173271554, + 465.14688934958235, + 287.09411718414964, + ], + Array [ + 465.16167826653003, + 286.98567733572514, + ], + Array [ + 465.2103190543207, + 286.88763659646884, + ], + Array [ + 465.2877190096327, + 286.81025985766115, + ], + Array [ + 465.38577433671327, + 286.76164848428067, + ], + Array [ + 465.49421861693304, + 286.7468920999525, + ], + Array [ + 465.6016977055264, + 286.7675357020111, + ], + Array [ + 465.69695851354595, + 286.8214178998716, + ], + Array [ + 465.77002720924565, + 286.9028972131945, + ], + Array [ + 465.8132534808974, + 287.00344273636637, + ], + Array [ + 465.82211152644874, + 287.11252732656965, + ], + Array [ + 465.7956739061921, + 287.21872979841464, + ], + Array [ + 465.7367086459472, + 287.31093072506434, + ], + Array [ + 465.651389424027, + 287.3794766451599, + ], + Array [ + 465.5486491854886, + 287.41719078277293, + ], + Array [ + 465.43924486042783, + 287.4201244577398, + ], + Array [ + 465.3346311105584, + 287.387970513517, + ], + Array [ + 465.2457610231071, + 287.32409547655254, + ], + Array [ + 465.24583276251474, + 287.32416723748526, + ], + Array [ + 465.04122440043375, + 287.3808800673476, + ], + Array [ + 464.828989270034, + 287.3869773067777, + ], + Array [ + 464.6214624870662, + 287.3421045839332, + ], + Array [ + 464.4307055179069, + 287.2488699035742, + ], + Array [ + 464.2678051665665, + 287.1126920697039, + ], + Array [ + 464.1422292091186, + 286.94148574442494, + ], + Array [ + 464.0612761261103, + 286.74520144740677, + ], + Array [ + 464.02965091452955, + 286.53524723121444, + ], + Array [ + 464.0491916331594, + 286.32382564475773, + ], + Array [ + 464.11876257451496, + 286.12322452057504, + ], + Array [ + 464.2343202722158, + 285.94510280542903, + ], + Array [ + 464.3891485074422, + 285.79981294177315, + ], + Array [ + 464.5742486558881, + 285.69579918330936, ], ] `; @@ -1852,124 +1976,128 @@ Array [ 266.2468669394994, ], Array [ - 942.0755615241945, - 259.40770729203007, + 957.6602662835733, + 259.49321610477915, + ], + Array [ + 957.2533438954803, + 261.98419326225473, ], Array [ - 942.511804420255, - 256.926787989347, + 956.0723267104213, + 264.21483250641586, ], Array [ - 943.717395593794, - 254.71504244044834, + 954.2408675394303, + 265.95158531956736, ], Array [ - 945.566109330697, - 253.00404098814784, + 951.9507206411685, + 267.012613223714, ], Array [ - 947.8643848146972, - 251.97292593616186, + 949.4416650004237, + 267.2868263172075, ], Array [ - 950.3715919959341, - 251.7296553026213, + 946.9763994051083, + 266.7455144167738, ], Array [ - 952.8252256206935, - 252.29969958707508, + 944.8130378138189, + 265.4453530212809, ], Array [ - 954.9683896007668, - 253.6233750024638, + 943.1780847562354, + 263.522469372046, ], Array [ - 956.5766941017001, - 255.56209238337988, + 942.2427202490725, + 261.17818989473614, ], Array [ - 957.4817492176945, - 257.91286750826976, + 942.1048772031423, + 258.6579612694552, ], Array [ - 957.588795439194, - 260.42957360101303, + 942.7789878217409, + 256.225652098546, ], Array [ - 956.8866249985501, - 262.8487108693536, + 944.1944725451531, + 254.13592579426992, ], Array [ - 955.4487553262533, - 264.9169950027061, + 946.2031297491857, + 252.6075772523188, ], Array [ - 953.4257317565537, - 266.41787610633435, + 948.5946524943428, + 251.8006249684798, ], Array [ - 951.0293653912253, - 267.1942115324945, + 951.1186477179056, + 251.7995570598856, ], Array [ - 948.5105564212972, - 267.16471875713484, + 953.510852453697, + 252.60448533684786, ], Array [ - 946.133024810822, - 266.33248568162094, + 955.520802234399, + 254.13113359628824, ], Array [ - 944.1456987470236, - 264.7846473286472, + 956.9380547873969, + 256.21966136244725, ], Array [ - 942.7566517933851, - 262.68326278235975, + 957.6142233962735, + 258.6513992268904, ], Array [ - 942.1113175326251, - 260.24834755946637, + 957.4785130291881, + 261.1717435932939, ], Array [ - 942.2772626321969, - 257.7348379265593, + 956.5451325973987, + 263.5168137411891, ], Array [ - 943.2371125963699, - 255.405899005706, + 954.9118072785022, + 265.44108020705295, ], Array [ - 944.8903708805198, - 253.50537131669998, + 952.749546664543, + 266.7430717839524, ], Array [ - 947.0639409058779, - 252.23224061027074, + 950.284740012584, + 267.28646961009383, ], Array [ - 949.5302493170226, - 251.71980400745528, + 947.7754532297312, + 267.0143797896371, ], Array [ - 952.031072972265, - 252.0217137558385, + 945.4844093045365, + 265.9552901986086, ], Array [ - 954.3045749747477, - 253.1063598250683, + 943.6514811407446, + 264.2200877967618, ], Array [ - 956.1127190646645, - 254.8601794853775, + 942.4685768009508, + 261.99044873361873, ], Array [ - 957.2661920784976, - 257.0995473553683, + 942.0595466817877, + 259.4998168076582, ], Array [ - 957.6442250872112, - 259.590001027917, + 942.0595476718931, + 259.502156915616, ], Array [ 957.4176762060673, @@ -4913,124 +5041,128 @@ Array [ 32.948280106751994, ], Array [ - 649.1494981791022, - 36.42904797963666, + 653.5198287974661, + 31.151000084366057, ], Array [ - 646.7029355814254, - 37.09997252361578, + 652.5298193264238, + 33.49372722956632, ], Array [ - 644.1702170478848, - 36.954558913785995, + 650.8435776532682, + 35.39769105520095, ], Array [ - 641.8165188775146, - 36.00803199348195, + 648.6376537263034, + 36.663546046128374, ], Array [ - 639.8882738900686, - 34.359493381118305, + 646.1430083629899, + 37.158756850645226, ], Array [ - 638.5873698447397, - 32.18154550458147, + 643.6208315913891, + 36.83147476679562, ], Array [ - 638.050011738479, - 29.702220081467264, + 641.3351959852776, + 35.715966315152706, ], Array [ - 638.332461106861, - 27.18110313805408, + 639.5254081959644, + 33.92902552506912, ], Array [ - 639.4051454264567, - 24.88215628382753, + 638.3809534827282, + 31.657745568973173, ], Array [ - 641.155754365843, - 23.04607986128816, + 638.0216565561516, + 29.139930057827794, ], Array [ - 643.4009987069505, - 21.865111556552947, + 638.4851358992923, + 26.639194940288643, ], Array [ - 645.9058007745782, - 21.46289906287302, + 639.7228651025767, + 24.417367843292034, ], Array [ - 648.4079071310421, - 21.88155413451046, + 641.6052535916924, + 22.70707465039891, ], Array [ - 650.6453465803282, - 23.07724347495062, + 643.9352147949265, + 21.687383510378726, ], Array [ - 652.3838586214699, - 24.92477809461808, + 646.4688011592505, + 21.465056354763924, ], Array [ - 653.441420584837, - 27.230720631131895, + 648.9407455235175, + 22.06337089543604, ], Array [ - 653.7073054536955, - 29.753638292209327, + 651.0922346602592, + 23.419683442046995, ], Array [ - 653.1536750120894, - 32.22938093275001, + 652.6980070889206, + 25.3919877129349, ], Array [ - 651.8384945133989, - 34.39873764475674, + 653.589938012338, + 27.7737829303, ], Array [ - 649.899463703011, - 36.03457620782787, + 653.6746420273829, + 30.315694506151324, ], Array [ - 647.5395996186276, - 36.96562389259039, + 652.9432506013203, + 32.75158362749772, ], Array [ - 645.0059806528272, - 37.09439976067696, + 651.4723406095276, + 34.82641206032197, ], Array [ - 642.5638773801398, - 36.40742094470538, + 649.4159167164279, + 36.32294472000585, ], Array [ - 640.4689786578683, - 34.976614308052675, + 646.9892870464721, + 37.0844942420342, ], Array [ - 638.940620935234, - 32.95178568327265, + 644.4465203666724, + 37.03132619042109, ], Array [ - 638.1388236692441, - 30.544935161882613, + 642.0538450196292, + 36.16900727420544, ], Array [ - 638.1475352453016, - 28.00806062881896, + 640.0617747457828, + 34.587822511545106, ], Array [ - 638.9658435590935, - 25.606773517363262, + 638.6788798286605, + 32.45332236448286, ], Array [ - 640.5080715141537, - 23.59248922196318, + 638.0499497311336, + 29.988989561869428, ], Array [ - 642.6127474364786, - 22.176103840066517, + 638.2408336004348, + 27.452840398659134, + ], + Array [ + 638.2402788764778, + 27.455132247955856, ], Array [ 649.416744639737, @@ -6910,124 +7042,128 @@ Array [ 389.35179380151266, ], Array [ - 833.6745621049283, - 394.3458087211475, + 834.110099985006, + 392.0869593397828, ], Array [ - 832.3850896044805, - 396.8306387321483, + 833.5191032270263, + 394.82911259528305, ], Array [ - 830.3696867754716, - 398.7736443805714, + 832.0834446148543, + 397.2390018030869, ], Array [ - 827.8393668261134, - 399.97139246212316, + 829.9534379841616, + 399.0643109269884, ], Array [ - 825.0590549230432, - 400.29847843649037, + 827.3520955914487, + 400.1139296198802, ], Array [ - 822.3198504564436, - 399.72065631581444, + 824.5517786719205, + 400.27796252754405, ], Array [ - 819.9085488570474, - 398.29842422866034, + 821.8456811462632, + 399.53923536124717, ], Array [ - 818.0776140388332, - 396.18069024998596, + 819.5171321397538, + 397.9750930503058, ], Array [ - 817.0187453605877, - 393.589181686386, + 817.809931348051, + 395.749301707569, ], Array [ - 816.8428066524375, - 390.7952301685611, + 816.9028231447031, + 393.09490227417314, ], Array [ - 817.5682187435693, - 388.0913631579592, + 816.8907819980543, + 390.2898110714882, ], Array [ - 819.1190307965513, - 385.7606762443419, + 817.7750686193369, + 387.62772188890744, ], Array [ - 821.3328723800618, - 384.04719296280643, + 819.463097965874, + 385.3873561665704, ], Array [ - 823.9779536959096, - 383.1303154652453, + 821.7781329194863, + 383.80328078700484, ], Array [ - 826.777334032092, - 383.1060410676853, + 824.4777887094211, + 383.04134886060655, ], Array [ - 829.4379175284458, - 383.9769113059587, + 827.279410661832, + 383.18133486119996, ], Array [ - 831.6811403905773, - 385.65174583623093, + 829.8896682187454, + 384.2085822175702, ], Array [ - 833.2721365926677, - 387.9551890410691, + 832.0352667249113, + 386.0155378603384, ], Array [ - 834.0443284123761, - 390.64606980887675, + 833.4915614503511, + 388.41301305671664, ], Array [ - 833.91686716234, - 393.44265221294074, + 834.106077952887, + 391.14999152077223, ], Array [ - 832.9030980690849, - 396.0521333373297, + 833.8144761924865, + 393.9399108848264, ], Array [ - 831.1091630242835, - 398.20129981948384, + 832.6472869504393, + 396.4906658549955, ], Array [ - 828.7228875006795, - 399.6651333613968, + 830.7267152484956, + 398.5351917125688, ], Array [ - 825.9941151755096, - 400.2903702048158, + 828.2538454508306, + 399.85942606055613, ], Array [ - 823.2085492315452, - 400.0115478871884, + 825.4875876780341, + 400.32472121315914, ], Array [ - 820.6578391584374, - 398.85785917877206, + 822.717569849139, + 399.8823606450744, ], Array [ - 818.6090449741624, - 396.95009559188225, + 820.2338135620442, + 398.57865962455224, ], Array [ - 817.2766759706433, - 394.488000477667, + 818.2963687556568, + 396.5501159925849, ], Array [ - 816.8002315342594, - 391.72935584451466, + 817.1080864126411, + 394.00911880292296, ], Array [ - 817.2295955232695, - 388.96299251372767, + 816.7933800079869, + 391.221711132082, + ], + Array [ + 816.7932502207548, + 391.22430864009806, ], Array [ 818.402936697633, @@ -8227,124 +8363,128 @@ Array [ -59.405717004495735, ], Array [ - 5.821367364768338, - -66.92242289001233, + 6.812014813329286, + -65.54894112195734, ], Array [ - 4.846412724498045, - -69.31826746872855, + 5.34663135357798, + -67.70036269475662, ], Array [ - 4.687517415442487, - -71.90000333374428, + 4.644934202531846, + -70.20707061077566, ], Array [ - 5.36131781840407, - -74.39732205848033, + 4.780391237135472, + -72.80661188950066, ], Array [ - 6.797266853326683, - -76.54875371322869, + 5.738820070108675, + -75.22681387283684, ], Array [ - 8.845020277200197, - -78.12904283581442, + 7.4198729496385205, + -77.21428077425765, ], Array [ - 11.29017776599065, - -78.97273273794696, + 9.64754319548337, + -78.560924284544, ], Array [ - 13.87673068516279, - -78.99148886416054, + 12.188593144855435, + -79.12575047268956, ], Array [ - 16.333866261295633, - -78.18334744308947, + 14.776974197283414, + -78.84962188769585, ], Array [ - 18.404321750947275, - -76.6329210948485, + 17.14168217331186, + -77.76144926530257, ], Array [ - 19.871319917804016, - -74.50253986737125, + 19.035131523628316, + -75.975164566324, ], Array [ - 20.58126566654605, - -72.01525523754066, + 20.25907760143256, + -73.67779227027653, ], Array [ - 20.45982748987261, - -69.43148656267932, + 20.685372929288096, + -71.10986786300373, ], Array [ - 19.51971999693797, - -67.02175510509393, + 20.269384273837417, + -68.54025370781328, ], Array [ - 17.859372690416663, - -65.038360384501, + 19.054665757116553, + -66.23798908506586, ], Array [ - 15.652624371590584, - -63.68896435171198, + 17.168398728480714, + -64.444121708502, ], Array [ - 13.130522171965831, - -63.11484912756582, + 14.80807584375423, + -63.3464699659829, ], Array [ - 10.557130857613412, - -63.37612472758234, + 12.220823532032673, + -63.05995828470223, ], Array [ - 8.201885178455374, - -64.44543552746973, + 9.67752779332159, + -63.61458451332184, ], Array [ - 6.3113799788240295, - -66.21082440420915, + 7.444472362828884, + -64.95227913929813, ], Array [ - 5.083551652165694, - -68.48745467638858, + 5.755458733596541, + -66.93298518217429, ], Array [ - 4.646954148396688, - -71.03696255353883, + 4.787327078461473, + -69.3493221964056, ], Array [ - 5.047299341412178, - -73.59241388791752, + 4.641441037278266, + -71.94829905875098, ], Array [ - 6.242670983822578, - -75.88625225024157, + 5.3330749170689735, + -74.45780220565963, ], Array [ - 8.107913349120048, - -77.67831215846114, + 6.789814468045898, + -76.61508599520573, ], Array [ - 10.44773506928178, - -78.78096446712777, + 8.859138674679858, + -78.19428224515616, ], Array [ - 13.01715619255388, - -79.07876118845212, + 11.32438874628773, + -79.0300486912738, ], Array [ - 15.547157649068478, - -78.54052292710082, + 13.927452349609373, + -79.03488036602924, ], Array [ - 17.772847618472962, - -77.22260337111847, + 16.395788038234947, + -78.20827139180011, ], Array [ - 19.46119577344559, - -75.26298904591339, + 18.470960413988006, + -76.6367679463918, + ], + Array [ + 18.469297239951885, + -76.638516788245, ], Array [ 23.728589484320054, @@ -8760,124 +8900,128 @@ Array [ -3.2375247496049404, ], Array [ - 27.233504226991474, - -2.164884075559332, + 26.750394037910247, + -2.5418384768523667, + ], + Array [ + 28.801431236028982, + -1.774779649844759, ], Array [ - 29.138884730429186, - -1.2632963025445951, + 30.5001657892464, + -0.39295703103210844, ], Array [ - 30.65663111902281, - 0.19950282079436654, + 31.668739741418264, + 1.4589521866301545, ], Array [ - 31.627834945240455, - 2.070357840102496, + 32.184803091278624, + 3.5870526191962346, ], Array [ - 31.950810912104224, - 4.153389741000471, + 31.994323869869596, + 5.768531589612508, ], Array [ - 31.591743350626107, - 6.230504533597254, + 31.11724530195434, + 7.774987673821868, ], Array [ - 30.58822672927749, - 8.08422775080291, + 29.64539774511984, + 9.396344390154628, ], Array [ - 29.045329503216237, - 9.520474082440597, + 27.732884027096688, + 10.462845262414142, ], Array [ - 27.12459341929627, - 10.388868158455637, + 25.579944839016505, + 10.862827367745947, ], Array [ - 25.0271200525291, - 10.598488889855487, + 23.411993482192027, + 10.554412474136786, ], Array [ - 22.97251541809444, - 10.127388930728081, + 21.456015035966367, + 9.569891702361161, ], Array [ - 21.175897163580554, - 9.024892571152371, + 19.916800959987505, + 8.012344637112221, ], Array [ - 19.8253716944962, - 7.406431471006707, + 18.955507374323492, + 6.044846867274033, ], Array [ - 19.062339383958616, - 5.441458934708581, + 18.672781971150208, + 3.873395928717618, ], Array [ - 18.96668991630205, - 3.3357081055107782, + 19.098226174812154, + 1.7253433079172087, ], Array [ - 19.548437816039158, - 1.3096516510945375, + 20.18729586487956, + -0.17440931869855447, ], Array [ - 20.746673924500925, - -0.42458178293578275, + 21.825965157315895, + -1.626957349637026, ], Array [ - 22.435942604827794, - -1.6854174982440577, + 23.842664944636386, + -2.480218622623501, ], Array [ - 24.439376980265916, - -2.3408456626091994, + 26.026246226751542, + -2.644856457137199, ], Array [ - 26.547216942851616, - -2.3222427742059484, + 28.14808746701442, + -2.103633228444366, ], Array [ - 28.538771092086442, - -1.6315565603608118, + 29.986031327457816, + -0.9132151514581981, ], Array [ - 30.20552318282629, - -0.3411020499868247, + 31.347644600723243, + 0.801760686920995, ], Array [ - 31.372963831190866, - 1.4140098290329428, + 32.09036601766882, + 2.8617358637052654, ], Array [ - 31.918861693121997, - 3.4500183996605904, + 32.13643244988092, + 5.051030434104662, ], Array [ - 31.78606111837246, - 5.553753027097333, + 31.48102072974659, + 7.140424678680727, ], Array [ - 30.988466362174467, - 7.504952140518536, + 30.19275263737579, + 8.911158468479826, ], Array [ - 29.609585806046532, - 9.099324677682448, + 28.40651018210947, + 10.177835508281682, ], Array [ - 27.793788608204352, - 10.169939413074548, + 26.30931342053625, + 10.80783437764877, ], Array [ - 25.731189214585914, - 10.604702701284436, + 24.12073940719901, + 10.735194028654806, ], Array [ - 23.637742326176433, - 10.35809471127017, + 24.122730962089754, + 10.735588476852367, ], Array [ 11.363981139577065, @@ -8957,124 +9101,128 @@ Array [ -4.260084650326611, ], Array [ - 27.479231754450787, - -3.227936155893045, + 26.9390809421517, + -3.495262304754778, ], Array [ - 29.711192966667422, - -2.1922338817107, + 29.284679389738272, + -2.6180417475230984, ], Array [ - 31.495599240631122, - -0.49806024744973243, + 31.22737898316504, + -1.037767634259878, ], Array [ - 32.64562276842038, - 1.6772043201643263, + 32.56377856217733, + 1.0801049182243707, ], Array [ - 33.040855783098934, - 4.105809046688208, + 33.15395673807734, + 3.5138340946204885, ], Array [ - 32.63991728369855, - 6.533478376165474, + 32.936121700056425, + 6.008607807717692, ], Array [ - 31.484785636943936, - 8.706034688957391, + 31.933080834098234, + 8.303222591198406, ], Array [ - 29.69640343117544, - 10.396010765615479, + 30.249852783645668, + 10.157431671512718, ], Array [ - 27.462014755424082, - 11.426465664803269, + 28.062671969910166, + 11.377098868488062, ], Array [ - 25.015560693862355, - 11.689510486562131, + 25.600536801449493, + 11.834524704640245, ], Array [ - 22.61318563253692, - 11.15760436861682, + 23.121233480342045, + 11.481816574175442, ], Array [ - 20.506418874533978, - 9.88643802192579, + 20.884345718780292, + 10.35590311145922, ], Array [ - 18.915839455548856, - 8.009102898542919, + 19.124076255880766, + 8.57466775325026, ], Array [ - 18.007981460621483, - 5.722156481454736, + 18.02472576907506, + 6.324606311753508, ], Array [ - 17.877897861471986, - 3.2650426642255983, + 17.701396544532077, + 3.8413008138522087, ], Array [ - 18.539208445270063, - 0.895021912134446, + 18.187941237412094, + 1.3847540007056098, ], Array [ - 19.922673819323, - -1.139763976450043, + 19.43341848993524, + -0.7878330278844405, ], Array [ - 21.88344479376807, - -2.626272381861779, + 21.307426504988285, + -2.448989836517307, ], Array [ - 24.216228129987606, - -3.408865481654038, + 23.613756148705097, + -3.424792868826307, ], Array [ - 26.676780796884433, - -3.4056055716940588, + 26.110934098576635, + -3.6130752897417127, ], Array [ - 29.007482280711617, - -2.616833965415185, + 28.53750516406038, + -2.994123880091945, ], Array [ - 30.964307520867028, - -1.1251352582102916, + 30.639406714047645, + -1.632743015854639, ], Array [ - 32.342376398154684, - 0.913309301506045, + 32.19656910140663, + 0.3285303671149089, ], Array [ - 32.99740473734773, - 3.285074030234431, + 33.045957013129915, + 2.6843504278939045, ], Array [ - 32.86081089842195, - 5.7418345347919155, + 33.09863931064342, + 5.188062184242683, ], Array [ - 31.946896292370152, - 8.026367341829541, + 32.349100143490716, + 7.57752635435581, ], Array [ - 30.35134801969599, - 9.899481263392367, + 30.875816460331823, + 9.60256540886515, ], Array [ - 28.241220405732278, - 11.165060777438732, + 28.83304145170258, + 11.051157224205202, ], Array [ - 25.837444368680607, - 11.690599374767423, + 26.43465420024671, + 11.77163385491875, ], Array [ - 23.391695894155546, - 11.421073025509408, + 23.93176648430439, + 11.688561207582723, + ], + Array [ + 23.9340440578483, + 11.689012304754778, ], Array [ 11.33651033834597, @@ -9142,56 +9290,180 @@ Array [ exports[`getStroke creates a stroke for "onePoint" with default values.: default_onePoint 1`] = ` Array [ Array [ - 472.54780354692497, - 284.1300930735467, + 469.8101723753737, + 282.75982762462627, + ], + Array [ + 470.9648255891402, + 284.36732752782905, + ], + Array [ + 471.5457396171903, + 286.2593684562639, + ], + Array [ + 471.49209260744067, + 288.23785322527357, + ], + Array [ + 470.8095014159735, + 290.0956339572734, + ], + Array [ + 469.5694335207221, + 291.63820051921647, + ], + Array [ + 467.90172435766533, + 292.7040457848694, + ], + Array [ + 465.9809835164078, + 293.1815754735625, + ], + Array [ + 464.00831307005535, + 293.0207921008339, + ], + Array [ + 462.19025213507564, + 292.2385297282511, + ], + Array [ + 460.71715217128246, + 290.91669143272065, + ], + Array [ + 459.7432471337456, + 289.19367403271605, + ], + Array [ + 459.37050513698114, + 287.2498779048502, + ], + Array [ + 459.63795236644467, + 285.28881901682297, + ], + Array [ + 460.5175870266121, + 283.51582075188014, + ], + Array [ + 461.9173111363629, + 282.11651649638725, + ], + Array [ + 463.69057321191497, + 281.2374137752749, + ], + Array [ + 465.65171224586214, + 280.9705548755041, + ], + Array [ + 467.5953964636598, + 281.34387999432477, + ], + Array [ + 469.31812161462176, + 282.31830189324813, + ], + Array [ + 470.63951792068696, + 283.79179834223453, ], Array [ - 472.77891488138135, - 287.9522824236518, + 471.4212348397956, + 285.61009387410974, ], Array [ - 471.2072401265814, - 291.44404162813544, + 471.5814264041639, + 287.5828124667031, ], Array [ - 468.1928535020967, - 293.8054008035043, + 471.10332051471596, + 289.50340996262287, ], Array [ - 464.42635776017187, - 294.49536725416266, + 470.03697498428465, + 291.17079929705784, ], Array [ - 460.77066554265707, - 293.35586811516646, + 468.49403647139405, + 292.4104043665446, ], Array [ - 458.06330415486497, - 290.64796520094234, + 466.63605104564004, + 293.09243819308386, ], Array [ - 456.92453617709737, - 286.9920451567151, + 464.65755027155956, + 293.14549165499756, ], Array [ - 457.61525591309976, - 283.22568748340944, + 462.76568370247224, + 292.56401004081863, ], Array [ - 459.97721791856236, - 280.21177319104436, + 461.15853026756594, + 291.4088746290478, ], Array [ - 463.4692913881596, - 278.64079681951415, + 461.1598276246263, + 291.4101723753737, ], Array [ - 467.2914344395544, - 278.87267258721323, + 460.09608311652863, + 290.3702702486252, ], Array [ - 470.56798550719765, - 280.85427723448703, + 459.31212368387924, + 289.1060090336526, + ], + Array [ + 458.8535130857379, + 287.6908676516711, + ], + Array [ + 458.74690579161626, + 286.20709418629167, + ], + Array [ + 458.99849782245764, + 284.740925621037, + ], + Array [ + 459.5936666376085, + 283.37757574180716, + ], + Array [ + 460.49782099756845, + 282.19628250763986, + ], + Array [ + 461.65841140845504, + 281.26570273680767, + ], + Array [ + 463.0079843010575, + 280.63992176931447, + ], + Array [ + 464.46810243544826, + 280.3553100243932, + ], + Array [ + 465.9539036770533, + 280.42840915003103, + ], + Array [ + 467.37903318790035, + 280.85497062161136, + ], + Array [ + 468.6606623738596, + 281.61020266636405, ], ] `; @@ -10951,124 +11223,128 @@ Array [ 334.2043174754342, ], Array [ - 7.508275519151073, - 340.78010030836725, + 7.546951937116137, + 340.6438769754257, ], Array [ - 7.067961377797392, - 343.1696356175752, + 7.148110734262704, + 343.0528934126855, ], Array [ - 5.887692034003979, - 345.29348114235535, + 6.000922670190244, + 345.20844300518644, ], Array [ - 4.091041999626851, - 346.92926969562257, + 4.2254986380353845, + 346.8848391415839, ], Array [ - 1.8661210075348444, - 347.9057337840435, + 2.0077260026311654, + 347.9065627038714, ], Array [ - -0.554121127077908, - 348.12063735979893, + -0.4201938556604724, + 348.16663896536863, ], Array [ - -2.916284413835576, - 347.55147996177834, + -2.804057086767797, + 347.6378378728435, ], Array [ - -4.973049733064082, - 346.2578525197974, + -4.894272581115093, + 346.3755250402731, ], Array [ - -6.509073212906881, - 344.3751981685159, + -6.471994224680891, + 344.51186495444597, ], Array [ - -7.363532789553619, - 342.10063131548566, + -7.372034144905791, + 342.24198331830655, ], Array [ - -7.446966319773956, - 339.67229971064614, + -7.5001579245547765, + 339.80353733834926, ], Array [ - -6.750638290929511, - 337.3444503140414, + -6.842950970077209, + 337.4518329523629, ], Array [ - -5.347454431453046, - 335.3608095719885, + -5.469223023092677, + 335.4330942303498, ], Array [ - -3.3843284618363105, - 333.92906519381074, + -3.5228037622794184, + 333.95868364940014, ], Array [ - -1.0668001893131074, - 333.199121193847, + -1.2074837980493693, + 333.18297238654577, ], Array [ - 1.3624845642153434, - 333.24740290158013, + 1.2343222581574795, + 333.18717761577557, ], Array [ - 3.6491790437856975, - 334.0688552094653, + 3.546956667682054, + 333.9708590484791, ], Array [ - 5.553865733758239, - 335.5774718440245, + 5.488285997370953, + 335.4519650317804, ], Array [ - 6.8771234349043775, - 337.61530024538337, + 6.855052553944567, + 337.4754233782539, ], Array [ - 7.4804067166080115, - 339.96897924198515, + 7.504155518138316, + 339.8293774648826, ], Array [ - 7.300551660023447, - 342.39207802157466, + 7.367633638254568, + 342.26736767741306, ], Array [ - 6.356389137052211, - 344.630897502293, + 6.459780791155428, + 344.53413579702635, ], Array [ - 4.746773213084096, - 346.451032693518, + 4.875649409582057, + 346.39235060323034, ], Array [ - 2.6402311002558965, - 347.66191496025937, + 2.781098467355252, + 347.6474565152944, ], Array [ - 0.2573183138538371, - 348.13676460954736, + 0.39542800103391196, + 348.16804361290957, ], Array [ - -2.152473548357899, - 347.8258647577535, + -2.0315816618022757, + 347.89960628953395, ], Array [ - -4.336838642282462, - 346.7617667014301, + -4.245821968786023, + 346.87025000378554, ], Array [ - -6.067073365969587, - 345.0558817879688, + -6.015461375273477, + 345.1877486305059, ], Array [ - -7.162021687111611, - 342.886816618119, + -7.155218168265957, + 343.0282605076145, ], Array [ - -7.50704222744668, - 340.48167288774147, + -7.545759510670574, + 340.61788461162774, + ], + Array [ + -7.545763409525173, + 340.6201485183619, ], Array [ -7.079383975548769, @@ -12965,56 +13241,212 @@ Array [ exports[`getStroke creates a stroke for "twoPoints" with default values.: default_twoPoints 1`] = ` Array [ Array [ - 4.930805185122358, - 197.33938185212202, + 4.893206982421875, + 200, + ], + Array [ + 5.19757506225586, + 171.25, + ], + Array [ + 5.4182419201354985, + 130.28125, + ], + Array [ + 5.578225392098236, + 84.11953125, + ], + Array [ + 5.694213409271221, + 35.75080078125, + ], + Array [ + 5.919621905604509, + 34.375914323509875, + ], + Array [ + 6.572247065536214, + 33.14497884082992, + ], + Array [ + 7.583758862545174, + 32.186873603182136, + ], + Array [ + 8.848251744471371, + 31.60191248186346, + ], + Array [ + 10.233332972783426, + 31.451341060690705, + ], + Array [ + 11.593984177251135, + 31.750924207207646, + ], + Array [ + 12.787744817589694, + 32.469295486891696, + ], + Array [ + 13.689627839633445, + 33.53124123712833, + ], + Array [ + 14.205205852900416, + 34.82557545754132, + ], + Array [ + 14.280497703302178, + 36.21678101358238, + ], + Array [ + 13.907620314226547, + 37.55919831629139, + ], + Array [ + 13.125614046739813, + 38.71227591971099, + ], + Array [ + 12.016355163477442, + 39.55528629438021, + ], + Array [ + 10.695983362332912, + 39.99996603153805, + ], + Array [ + 9.302741919430359, + 39.999757045320045, + ], + Array [ + 7.982503581621712, + 39.554681216638386, + ], + Array [ + 6.8734976513846, + 38.711338102244646, + ], + Array [ + 6.091837342363988, + 37.558025948836814, ], Array [ - 6.747974298276899, - 195.28831730319916, + 5.719362695252612, + 36.215496843321525, ], Array [ - 9.310189810502598, - 194.3167098523421, + 5.795071903926794, + 34.82431393743951, ], Array [ - 12.030442387889039, - 194.64715695079116, + 6.3110381942530545, + 33.53013444867322, ], Array [ - 14.285516049617891, - 196.20395242542097, + 7.213239759432362, + 32.4684593111267, ], Array [ - 15.558768350206307, - 198.63043093319664, + 8.407215857432362, + 31.75044619195609, ], Array [ - 15.558494325219405, - 201.37068079307463, + 9.767956875613374, + 31.451271254275607, ], Array [ - 14.284756754397714, - 203.7969046018623, + 11.1529928701711, + 31.602258193034906, ], Array [ - 12.029371778677488, - 205.35324903062684, + 12.417310206861348, + 32.187598635889216, ], Array [ - 9.309053166276847, - 205.68315207195513, + 13.428534526785299, + 33.14600728395681, ], Array [ - 6.747032026784339, - 204.71103219743117, + 14.08079037670961, + 34.37713849878971, ], Array [ - 4.930273162880228, - 202.6596042557094, + 14.305786396968383, + 35.75209251720783, ], Array [ - 4.2750001145, - 199.99885500000764, + 14.30578659072878, + 35.75080078125, + ], + Array [ + 14.421774607901764, + 84.11953125, + ], + Array [ + 14.581758079864501, + 130.28125, + ], + Array [ + 14.80242493774414, + 171.25, + ], + Array [ + 15.106793017578125, + 200, + ], + Array [ + 14.958389492516485, + 201.22217370487456, + ], + Array [ + 14.521804137180853, + 202.37331461659824, + ], + Array [ + 13.822411312936213, + 203.3865183712955, + ], + Array [ + 12.900859763588496, + 204.2028975191382, + ], + Array [ + 11.8107101084847, + 204.7750040656963, + ], + Array [ + 10.615321896799927, + 205.06958715160349, + ], + Array [ + 9.384171147562364, + 205.069525594066, + ], + Array [ + 8.188812400163075, + 204.7748229708107, + ], + Array [ + 7.098719961164591, + 204.20260741214784, + ], + Array [ + 6.177250054339279, + 203.38613611323225, + ], + Array [ + 5.4779585539669045, + 202.3728624243187, + ], + Array [ + 5.04148831490518, + 201.22167785981526, + ], + Array [ + 4.89320700795584, + 199.9994893206991, ], ] `; @@ -14530,124 +14962,128 @@ Array [ 222.14857279717071, ], Array [ - 1488.4850608620916, - 205.21853389949246, + 1488.5474613032166, + 205.28091342498985, ], Array [ - 1489.6204613263242, - 204.40269706821584, + 1489.659676606655, + 204.48173618538223, ], Array [ - 1490.9569293728503, - 203.99211563894497, + 1490.9688536421845, + 204.0795389313487, ], Array [ - 1492.354536444405, - 204.02977759570746, + 1492.3379212285959, + 204.1164318215564, ], Array [ - 1493.6669527116644, - 204.51173972168849, + 1493.6235376281927, + 204.58855216066175, ], Array [ - 1494.756767845002, - 205.3875404550722, + 1494.691098464568, + 205.44646882453276, ], Array [ - 1495.5098779122743, - 206.56548322788439, + 1495.4288298363442, + 206.60035771199415, ], Array [ - 1495.847432090636, - 207.9222371208649, + 1495.7594910741545, + 207.92940635193162, ], Array [ - 1495.7340883685067, - 209.3157496432705, + 1495.6484618591137, + 209.29446300090893, ], Array [ - 1495.1817138635138, - 210.60011966615363, + 1495.1073669793457, + 210.55260586743822, ], Array [ - 1494.2481423321422, - 211.64087330907776, + 1494.1928592115971, + 211.57210706127643, ], Array [ - 1493.0311189601657, - 212.3290433908964, + 1493.000687760558, + 212.24622453830645, ], Array [ - 1491.6580664158932, - 212.5925783223839, + 1491.6556732918552, + 212.50437802073358, ], Array [ - 1490.2727436631608, - 212.40388592664706, + 1490.2986391754107, + 212.31953877080178, ], Array [ - 1489.020194359869, - 211.7827223473295, + 1489.0716672414385, + 211.7110595067717, ], Array [ - 1488.0315607487137, - 210.79412357515696, + 1488.103221775315, + 210.74264816821022, ], Array [ - 1487.4103530297566, - 209.54159616254069, + 1487.4946992729876, + 209.51569767790056, ], Array [ - 1487.2216118151553, - 208.15628006021674, + 1487.309812201085, + 208.15867007606153, ], Array [ - 1487.4850983599015, - 206.78321822978634, + 1487.56791828484, + 206.81364651082623, ], Array [ - 1488.1732255532067, - 205.5661706073487, + 1488.2419937491509, + 205.6214513045265, ], Array [ - 1489.213946296284, - 204.6325624002424, + 1489.261462714965, + 204.7069076099709, ], Array [ - 1490.498296852609, - 204.0801426342001, + 1490.5195865124483, + 204.16576839339552, ], Array [ - 1491.8918053798996, - 203.96674980455106, + 1491.884639247892, + 204.05469107362265, ], Array [ - 1493.2485711674974, - 204.30425617049238, + 1493.2136995395558, + 204.38530547535407, ], Array [ - 1494.42654047929, - 205.05732472641697, + 1494.3676144240649, + 205.1229961834548, ], Array [ - 1495.3023796173786, - 206.14710899572867, + 1495.225568708407, + 206.19052678605524, ], Array [ - 1495.7843879928066, - 207.45950827775553, + 1495.697734352534, + 207.47612654726242, ], Array [ - 1495.8220992014285, - 208.8571140212295, + 1495.7346754888658, + 208.84519283271257, ], Array [ - 1495.4115648697468, - 210.19359653587682, + 1495.3325243706772, + 210.15438404092066, ], Array [ - 1494.5957680506594, - 211.32902574961676, + 1494.5333863262, + 211.26662750679438, + ], + Array [ + 1494.534284183319, + 211.26572961803421, ], Array [ 1477.672822129192, @@ -16279,124 +16715,128 @@ Array [ 46.11052040597133, ], Array [ - 14.129612003024915, - 21.803098556727228, + 14.406898944853781, + 21.525811614898366, + ], + Array [ + 13.456662205181654, + 20.202898857344188, ], Array [ - 13.105350408218428, - 20.377128928032562, + 12.978591520873394, + 18.64581939683893, ], Array [ - 12.590037306655162, - 18.698750661993472, + 13.022741018774472, + 17.017599863926556, ], Array [ - 12.637626116098236, - 16.943690406113085, + 13.584488234800315, + 15.488715273511204, ], Array [ - 13.243134275636738, - 15.295703432472994, + 14.605018087146153, + 14.219240245795694, ], Array [ - 14.343164921128356, - 13.927334412239624, + 15.977480830877656, + 13.342089151290704, ], Array [ - 15.822544553610225, - 12.981851943045752, + 17.558179254431163, + 12.949099941136309, ], Array [ - 17.526381735043202, - 12.558248288999108, + 19.181613815596755, + 13.08141868937475, ], Array [ - 19.276284262761916, - 12.700874864498882, + 20.677810487275295, + 13.725191588136706, ], Array [ - 20.88903688018481, - 13.394798629440485, + 21.890117082984474, + 14.813015444982257, ], Array [ - 22.19578396254237, - 14.567365582456453, + 22.691604782135684, + 16.230994814942065, ], Array [ - 23.059708745364023, - 16.095807654038392, + 22.99835761105558, + 17.83066688367114, ], Array [ - 23.39035807583435, - 17.820096555822158, + 22.778258467581374, + 19.444545563301126, ], Array [ - 23.153112881770163, - 19.55969878462292, + 22.054351790135343, + 20.90365733005217, ], Array [ - 22.37281279761663, - 21.132477527874848, + 20.902430798938884, + 22.055232796777343, ], Array [ - 21.131155448163838, - 22.373762435986208, + 19.443101925847895, + 22.77870170812411, ], Array [ - 19.558142685665217, - 23.153590651410333, + 17.829157289100394, + 22.998316678097225, ], Array [ - 17.818469361589404, - 23.390313954137667, + 16.229577318203866, + 22.691083961367784, ], Array [ - 16.0942797321963, - 23.05914735188378, + 14.811838458359269, + 21.889170904478913, ], Array [ - 14.566096906825212, - 22.194764075324144, + 13.724378342439053, + 20.676538016171378, ], Array [ - 13.39392203069359, - 20.88766528168958, + 13.08105433164165, + 19.180148279954956, ], Array [ - 12.700482122756526, - 19.274704559714188, + 12.949222619718594, + 17.556674096220046, ], Array [ - 12.558380524425392, - 17.524759322769086, + 13.342686021708426, + 15.976093640559247, ], Array [ - 12.982495310556633, - 15.821049299103091, + 14.220248815558557, + 14.603894103912967, ], Array [ - 13.928421551086881, - 14.341953377929807, + 15.4900299450988, + 13.583745139993574, ], Array [ - 15.29712051893234, - 13.242333292639481, + 17.01908299087662, + 13.0224566146166, ], Array [ - 16.94528907085815, - 12.637319556433523, + 18.647315695368288, + 12.978795584554788, ], Array [ - 18.70036352440344, - 12.590257267200807, + 20.204251664601827, + 13.457333371181011, ], Array [ - 20.37858712098736, - 13.106073859047239, + 21.526879291607308, + 14.407966941913791, ], Array [ - 21.804249407039563, - 14.130763198644143, + 21.525811614898366, + 14.406898944853781, ], Array [ 46.11052040597133, @@ -16880,124 +17320,128 @@ Array [ -59.405717004495735, ], Array [ - 5.821367364768338, - -66.92242289001233, + 6.812014813329286, + -65.54894112195734, ], Array [ - 4.846412724498045, - -69.31826746872855, + 5.34663135357798, + -67.70036269475662, ], Array [ - 4.687517415442487, - -71.90000333374428, + 4.644934202531846, + -70.20707061077566, ], Array [ - 5.36131781840407, - -74.39732205848033, + 4.780391237135472, + -72.80661188950066, ], Array [ - 6.797266853326683, - -76.54875371322869, + 5.738820070108675, + -75.22681387283684, ], Array [ - 8.845020277200197, - -78.12904283581442, + 7.4198729496385205, + -77.21428077425765, ], Array [ - 11.29017776599065, - -78.97273273794696, + 9.64754319548337, + -78.560924284544, ], Array [ - 13.87673068516279, - -78.99148886416054, + 12.188593144855435, + -79.12575047268956, ], Array [ - 16.333866261295633, - -78.18334744308947, + 14.776974197283414, + -78.84962188769585, ], Array [ - 18.404321750947275, - -76.6329210948485, + 17.14168217331186, + -77.76144926530257, ], Array [ - 19.871319917804016, - -74.50253986737125, + 19.035131523628316, + -75.975164566324, ], Array [ - 20.58126566654605, - -72.01525523754066, + 20.25907760143256, + -73.67779227027653, ], Array [ - 20.45982748987261, - -69.43148656267932, + 20.685372929288096, + -71.10986786300373, ], Array [ - 19.51971999693797, - -67.02175510509393, + 20.269384273837417, + -68.54025370781328, ], Array [ - 17.859372690416663, - -65.038360384501, + 19.054665757116553, + -66.23798908506586, ], Array [ - 15.652624371590584, - -63.68896435171198, + 17.168398728480714, + -64.444121708502, ], Array [ - 13.130522171965831, - -63.11484912756582, + 14.80807584375423, + -63.3464699659829, ], Array [ - 10.557130857613412, - -63.37612472758234, + 12.220823532032673, + -63.05995828470223, ], Array [ - 8.201885178455374, - -64.44543552746973, + 9.67752779332159, + -63.61458451332184, ], Array [ - 6.3113799788240295, - -66.21082440420915, + 7.444472362828884, + -64.95227913929813, ], Array [ - 5.083551652165694, - -68.48745467638858, + 5.755458733596541, + -66.93298518217429, ], Array [ - 4.646954148396688, - -71.03696255353883, + 4.787327078461473, + -69.3493221964056, ], Array [ - 5.047299341412178, - -73.59241388791752, + 4.641441037278266, + -71.94829905875098, ], Array [ - 6.242670983822578, - -75.88625225024157, + 5.3330749170689735, + -74.45780220565963, ], Array [ - 8.107913349120048, - -77.67831215846114, + 6.789814468045898, + -76.61508599520573, ], Array [ - 10.44773506928178, - -78.78096446712777, + 8.859138674679858, + -78.19428224515616, ], Array [ - 13.01715619255388, - -79.07876118845212, + 11.32438874628773, + -79.0300486912738, ], Array [ - 15.547157649068478, - -78.54052292710082, + 13.927452349609373, + -79.03488036602924, ], Array [ - 17.772847618472962, - -77.22260337111847, + 16.395788038234947, + -78.20827139180011, ], Array [ - 19.46119577344559, - -75.26298904591339, + 18.470960413988006, + -76.6367679463918, + ], + Array [ + 18.469297239951885, + -76.638516788245, ], Array [ 23.728589484320054, @@ -17401,56 +17845,180 @@ Array [ exports[`getStroke gets stroke from a line with a single point: get-stroke-one-point 1`] = ` Array [ Array [ - 472.54780354692497, - 284.1300930735467, + 469.8101723753737, + 282.75982762462627, + ], + Array [ + 470.9648255891402, + 284.36732752782905, + ], + Array [ + 471.5457396171903, + 286.2593684562639, + ], + Array [ + 471.49209260744067, + 288.23785322527357, + ], + Array [ + 470.8095014159735, + 290.0956339572734, + ], + Array [ + 469.5694335207221, + 291.63820051921647, + ], + Array [ + 467.90172435766533, + 292.7040457848694, + ], + Array [ + 465.9809835164078, + 293.1815754735625, + ], + Array [ + 464.00831307005535, + 293.0207921008339, + ], + Array [ + 462.19025213507564, + 292.2385297282511, + ], + Array [ + 460.71715217128246, + 290.91669143272065, + ], + Array [ + 459.7432471337456, + 289.19367403271605, + ], + Array [ + 459.37050513698114, + 287.2498779048502, + ], + Array [ + 459.63795236644467, + 285.28881901682297, + ], + Array [ + 460.5175870266121, + 283.51582075188014, + ], + Array [ + 461.9173111363629, + 282.11651649638725, + ], + Array [ + 463.69057321191497, + 281.2374137752749, + ], + Array [ + 465.65171224586214, + 280.9705548755041, + ], + Array [ + 467.5953964636598, + 281.34387999432477, + ], + Array [ + 469.31812161462176, + 282.31830189324813, + ], + Array [ + 470.63951792068696, + 283.79179834223453, + ], + Array [ + 471.4212348397956, + 285.61009387410974, + ], + Array [ + 471.5814264041639, + 287.5828124667031, + ], + Array [ + 471.10332051471596, + 289.50340996262287, + ], + Array [ + 470.03697498428465, + 291.17079929705784, + ], + Array [ + 468.49403647139405, + 292.4104043665446, + ], + Array [ + 466.63605104564004, + 293.09243819308386, + ], + Array [ + 464.65755027155956, + 293.14549165499756, + ], + Array [ + 462.76568370247224, + 292.56401004081863, + ], + Array [ + 461.15853026756594, + 291.4088746290478, + ], + Array [ + 461.1598276246263, + 291.4101723753737, ], Array [ - 472.77891488138135, - 287.9522824236518, + 460.09608311652863, + 290.3702702486252, ], Array [ - 471.2072401265814, - 291.44404162813544, + 459.31212368387924, + 289.1060090336526, ], Array [ - 468.1928535020967, - 293.8054008035043, + 458.8535130857379, + 287.6908676516711, ], Array [ - 464.42635776017187, - 294.49536725416266, + 458.74690579161626, + 286.20709418629167, ], Array [ - 460.77066554265707, - 293.35586811516646, + 458.99849782245764, + 284.740925621037, ], Array [ - 458.06330415486497, - 290.64796520094234, + 459.5936666376085, + 283.37757574180716, ], Array [ - 456.92453617709737, - 286.9920451567151, + 460.49782099756845, + 282.19628250763986, ], Array [ - 457.61525591309976, - 283.22568748340944, + 461.65841140845504, + 281.26570273680767, ], Array [ - 459.97721791856236, - 280.21177319104436, + 463.0079843010575, + 280.63992176931447, ], Array [ - 463.4692913881596, - 278.64079681951415, + 464.46810243544826, + 280.3553100243932, ], Array [ - 467.2914344395544, - 278.87267258721323, + 465.9539036770533, + 280.42840915003103, ], Array [ - 470.56798550719765, - 280.85427723448703, + 467.37903318790035, + 280.85497062161136, + ], + Array [ + 468.6606623738596, + 281.61020266636405, ], ] `; @@ -17517,56 +18085,212 @@ Array [ exports[`getStroke gets stroke from a line with two points: get-stroke-two-points 1`] = ` Array [ Array [ - 4.930805185122358, - 197.33938185212202, + 4.893206982421875, + 200, + ], + Array [ + 5.19757506225586, + 171.25, + ], + Array [ + 5.4182419201354985, + 130.28125, + ], + Array [ + 5.578225392098236, + 84.11953125, + ], + Array [ + 5.694213409271221, + 35.75080078125, + ], + Array [ + 5.919621905604509, + 34.375914323509875, + ], + Array [ + 6.572247065536214, + 33.14497884082992, ], Array [ - 6.747974298276899, - 195.28831730319916, + 7.583758862545174, + 32.186873603182136, ], Array [ - 9.310189810502598, - 194.3167098523421, + 8.848251744471371, + 31.60191248186346, ], Array [ - 12.030442387889039, - 194.64715695079116, + 10.233332972783426, + 31.451341060690705, ], Array [ - 14.285516049617891, - 196.20395242542097, + 11.593984177251135, + 31.750924207207646, ], Array [ - 15.558768350206307, - 198.63043093319664, + 12.787744817589694, + 32.469295486891696, ], Array [ - 15.558494325219405, - 201.37068079307463, + 13.689627839633445, + 33.53124123712833, ], Array [ - 14.284756754397714, - 203.7969046018623, + 14.205205852900416, + 34.82557545754132, ], Array [ - 12.029371778677488, - 205.35324903062684, + 14.280497703302178, + 36.21678101358238, ], Array [ - 9.309053166276847, - 205.68315207195513, + 13.907620314226547, + 37.55919831629139, ], Array [ - 6.747032026784339, - 204.71103219743117, + 13.125614046739813, + 38.71227591971099, ], Array [ - 4.930273162880228, - 202.6596042557094, + 12.016355163477442, + 39.55528629438021, ], Array [ - 4.2750001145, - 199.99885500000764, + 10.695983362332912, + 39.99996603153805, + ], + Array [ + 9.302741919430359, + 39.999757045320045, + ], + Array [ + 7.982503581621712, + 39.554681216638386, + ], + Array [ + 6.8734976513846, + 38.711338102244646, + ], + Array [ + 6.091837342363988, + 37.558025948836814, + ], + Array [ + 5.719362695252612, + 36.215496843321525, + ], + Array [ + 5.795071903926794, + 34.82431393743951, + ], + Array [ + 6.3110381942530545, + 33.53013444867322, + ], + Array [ + 7.213239759432362, + 32.4684593111267, + ], + Array [ + 8.407215857432362, + 31.75044619195609, + ], + Array [ + 9.767956875613374, + 31.451271254275607, + ], + Array [ + 11.1529928701711, + 31.602258193034906, + ], + Array [ + 12.417310206861348, + 32.187598635889216, + ], + Array [ + 13.428534526785299, + 33.14600728395681, + ], + Array [ + 14.08079037670961, + 34.37713849878971, + ], + Array [ + 14.305786396968383, + 35.75209251720783, + ], + Array [ + 14.30578659072878, + 35.75080078125, + ], + Array [ + 14.421774607901764, + 84.11953125, + ], + Array [ + 14.581758079864501, + 130.28125, + ], + Array [ + 14.80242493774414, + 171.25, + ], + Array [ + 15.106793017578125, + 200, + ], + Array [ + 14.958389492516485, + 201.22217370487456, + ], + Array [ + 14.521804137180853, + 202.37331461659824, + ], + Array [ + 13.822411312936213, + 203.3865183712955, + ], + Array [ + 12.900859763588496, + 204.2028975191382, + ], + Array [ + 11.8107101084847, + 204.7750040656963, + ], + Array [ + 10.615321896799927, + 205.06958715160349, + ], + Array [ + 9.384171147562364, + 205.069525594066, + ], + Array [ + 8.188812400163075, + 204.7748229708107, + ], + Array [ + 7.098719961164591, + 204.20260741214784, + ], + Array [ + 6.177250054339279, + 203.38613611323225, + ], + Array [ + 5.4779585539669045, + 202.3728624243187, + ], + Array [ + 5.04148831490518, + 201.22167785981526, + ], + Array [ + 4.89320700795584, + 199.9994893206991, ], ] `; @@ -17658,124 +18382,128 @@ Array [ 46.11052040597133, ], Array [ - 14.129612003024915, - 21.803098556727228, + 14.406898944853781, + 21.525811614898366, + ], + Array [ + 13.456662205181654, + 20.202898857344188, ], Array [ - 13.105350408218428, - 20.377128928032562, + 12.978591520873394, + 18.64581939683893, ], Array [ - 12.590037306655162, - 18.698750661993472, + 13.022741018774472, + 17.017599863926556, ], Array [ - 12.637626116098236, - 16.943690406113085, + 13.584488234800315, + 15.488715273511204, ], Array [ - 13.243134275636738, - 15.295703432472994, + 14.605018087146153, + 14.219240245795694, ], Array [ - 14.343164921128356, - 13.927334412239624, + 15.977480830877656, + 13.342089151290704, ], Array [ - 15.822544553610225, - 12.981851943045752, + 17.558179254431163, + 12.949099941136309, ], Array [ - 17.526381735043202, - 12.558248288999108, + 19.181613815596755, + 13.08141868937475, ], Array [ - 19.276284262761916, - 12.700874864498882, + 20.677810487275295, + 13.725191588136706, ], Array [ - 20.88903688018481, - 13.394798629440485, + 21.890117082984474, + 14.813015444982257, ], Array [ - 22.19578396254237, - 14.567365582456453, + 22.691604782135684, + 16.230994814942065, ], Array [ - 23.059708745364023, - 16.095807654038392, + 22.99835761105558, + 17.83066688367114, ], Array [ - 23.39035807583435, - 17.820096555822158, + 22.778258467581374, + 19.444545563301126, ], Array [ - 23.153112881770163, - 19.55969878462292, + 22.054351790135343, + 20.90365733005217, ], Array [ - 22.37281279761663, - 21.132477527874848, + 20.902430798938884, + 22.055232796777343, ], Array [ - 21.131155448163838, - 22.373762435986208, + 19.443101925847895, + 22.77870170812411, ], Array [ - 19.558142685665217, - 23.153590651410333, + 17.829157289100394, + 22.998316678097225, ], Array [ - 17.818469361589404, - 23.390313954137667, + 16.229577318203866, + 22.691083961367784, ], Array [ - 16.0942797321963, - 23.05914735188378, + 14.811838458359269, + 21.889170904478913, ], Array [ - 14.566096906825212, - 22.194764075324144, + 13.724378342439053, + 20.676538016171378, ], Array [ - 13.39392203069359, - 20.88766528168958, + 13.08105433164165, + 19.180148279954956, ], Array [ - 12.700482122756526, - 19.274704559714188, + 12.949222619718594, + 17.556674096220046, ], Array [ - 12.558380524425392, - 17.524759322769086, + 13.342686021708426, + 15.976093640559247, ], Array [ - 12.982495310556633, - 15.821049299103091, + 14.220248815558557, + 14.603894103912967, ], Array [ - 13.928421551086881, - 14.341953377929807, + 15.4900299450988, + 13.583745139993574, ], Array [ - 15.29712051893234, - 13.242333292639481, + 17.01908299087662, + 13.0224566146166, ], Array [ - 16.94528907085815, - 12.637319556433523, + 18.647315695368288, + 12.978795584554788, ], Array [ - 18.70036352440344, - 12.590257267200807, + 20.204251664601827, + 13.457333371181011, ], Array [ - 20.37858712098736, - 13.106073859047239, + 21.526879291607308, + 14.407966941913791, ], Array [ - 21.804249407039563, - 14.130763198644143, + 21.525811614898366, + 14.406898944853781, ], Array [ 46.11052040597133, diff --git a/packages/perfect-freehand/src/test/__snapshots__/getStrokeOutlinePoints.spec.ts.snap b/packages/perfect-freehand/src/test/__snapshots__/getStrokeOutlinePoints.spec.ts.snap index 53a0475..c529d0c 100644 --- a/packages/perfect-freehand/src/test/__snapshots__/getStrokeOutlinePoints.spec.ts.snap +++ b/packages/perfect-freehand/src/test/__snapshots__/getStrokeOutlinePoints.spec.ts.snap @@ -343,124 +343,128 @@ Array [ -59.405717004495735, ], Array [ - 5.821367364768338, - -66.92242289001233, + 6.812014813329286, + -65.54894112195734, ], Array [ - 4.846412724498045, - -69.31826746872855, + 5.34663135357798, + -67.70036269475662, ], Array [ - 4.687517415442487, - -71.90000333374428, + 4.644934202531846, + -70.20707061077566, ], Array [ - 5.36131781840407, - -74.39732205848033, + 4.780391237135472, + -72.80661188950066, ], Array [ - 6.797266853326683, - -76.54875371322869, + 5.738820070108675, + -75.22681387283684, ], Array [ - 8.845020277200197, - -78.12904283581442, + 7.4198729496385205, + -77.21428077425765, ], Array [ - 11.29017776599065, - -78.97273273794696, + 9.64754319548337, + -78.560924284544, ], Array [ - 13.87673068516279, - -78.99148886416054, + 12.188593144855435, + -79.12575047268956, ], Array [ - 16.333866261295633, - -78.18334744308947, + 14.776974197283414, + -78.84962188769585, ], Array [ - 18.404321750947275, - -76.6329210948485, + 17.14168217331186, + -77.76144926530257, ], Array [ - 19.871319917804016, - -74.50253986737125, + 19.035131523628316, + -75.975164566324, ], Array [ - 20.58126566654605, - -72.01525523754066, + 20.25907760143256, + -73.67779227027653, ], Array [ - 20.45982748987261, - -69.43148656267932, + 20.685372929288096, + -71.10986786300373, ], Array [ - 19.51971999693797, - -67.02175510509393, + 20.269384273837417, + -68.54025370781328, ], Array [ - 17.859372690416663, - -65.038360384501, + 19.054665757116553, + -66.23798908506586, ], Array [ - 15.652624371590584, - -63.68896435171198, + 17.168398728480714, + -64.444121708502, ], Array [ - 13.130522171965831, - -63.11484912756582, + 14.80807584375423, + -63.3464699659829, ], Array [ - 10.557130857613412, - -63.37612472758234, + 12.220823532032673, + -63.05995828470223, ], Array [ - 8.201885178455374, - -64.44543552746973, + 9.67752779332159, + -63.61458451332184, ], Array [ - 6.3113799788240295, - -66.21082440420915, + 7.444472362828884, + -64.95227913929813, ], Array [ - 5.083551652165694, - -68.48745467638858, + 5.755458733596541, + -66.93298518217429, ], Array [ - 4.646954148396688, - -71.03696255353883, + 4.787327078461473, + -69.3493221964056, ], Array [ - 5.047299341412178, - -73.59241388791752, + 4.641441037278266, + -71.94829905875098, ], Array [ - 6.242670983822578, - -75.88625225024157, + 5.3330749170689735, + -74.45780220565963, ], Array [ - 8.107913349120048, - -77.67831215846114, + 6.789814468045898, + -76.61508599520573, ], Array [ - 10.44773506928178, - -78.78096446712777, + 8.859138674679858, + -78.19428224515616, ], Array [ - 13.01715619255388, - -79.07876118845212, + 11.32438874628773, + -79.0300486912738, ], Array [ - 15.547157649068478, - -78.54052292710082, + 13.927452349609373, + -79.03488036602924, ], Array [ - 17.772847618472962, - -77.22260337111847, + 16.395788038234947, + -78.20827139180011, ], Array [ - 19.46119577344559, - -75.26298904591339, + 18.470960413988006, + -76.6367679463918, + ], + Array [ + 18.469297239951885, + -76.638516788245, ], Array [ 23.728589484320054, @@ -864,56 +868,180 @@ Array [ exports[`getStrokeOutlinePoints gets stroke outline points with a single point: get-stroke-outline-points-one-point 1`] = ` Array [ Array [ - 472.54780354692497, - 284.1300930735467, + 469.8101723753737, + 282.75982762462627, + ], + Array [ + 470.9648255891402, + 284.36732752782905, + ], + Array [ + 471.5457396171903, + 286.2593684562639, + ], + Array [ + 471.49209260744067, + 288.23785322527357, + ], + Array [ + 470.8095014159735, + 290.0956339572734, + ], + Array [ + 469.5694335207221, + 291.63820051921647, + ], + Array [ + 467.90172435766533, + 292.7040457848694, + ], + Array [ + 465.9809835164078, + 293.1815754735625, + ], + Array [ + 464.00831307005535, + 293.0207921008339, + ], + Array [ + 462.19025213507564, + 292.2385297282511, + ], + Array [ + 460.71715217128246, + 290.91669143272065, + ], + Array [ + 459.7432471337456, + 289.19367403271605, + ], + Array [ + 459.37050513698114, + 287.2498779048502, + ], + Array [ + 459.63795236644467, + 285.28881901682297, + ], + Array [ + 460.5175870266121, + 283.51582075188014, + ], + Array [ + 461.9173111363629, + 282.11651649638725, + ], + Array [ + 463.69057321191497, + 281.2374137752749, + ], + Array [ + 465.65171224586214, + 280.9705548755041, ], Array [ - 472.77891488138135, - 287.9522824236518, + 467.5953964636598, + 281.34387999432477, ], Array [ - 471.2072401265814, - 291.44404162813544, + 469.31812161462176, + 282.31830189324813, ], Array [ - 468.1928535020967, - 293.8054008035043, + 470.63951792068696, + 283.79179834223453, ], Array [ - 464.42635776017187, - 294.49536725416266, + 471.4212348397956, + 285.61009387410974, ], Array [ - 460.77066554265707, - 293.35586811516646, + 471.5814264041639, + 287.5828124667031, ], Array [ - 458.06330415486497, - 290.64796520094234, + 471.10332051471596, + 289.50340996262287, ], Array [ - 456.92453617709737, - 286.9920451567151, + 470.03697498428465, + 291.17079929705784, ], Array [ - 457.61525591309976, - 283.22568748340944, + 468.49403647139405, + 292.4104043665446, ], Array [ - 459.97721791856236, - 280.21177319104436, + 466.63605104564004, + 293.09243819308386, ], Array [ - 463.4692913881596, - 278.64079681951415, + 464.65755027155956, + 293.14549165499756, ], Array [ - 467.2914344395544, - 278.87267258721323, + 462.76568370247224, + 292.56401004081863, ], Array [ - 470.56798550719765, - 280.85427723448703, + 461.15853026756594, + 291.4088746290478, + ], + Array [ + 461.1598276246263, + 291.4101723753737, + ], + Array [ + 460.09608311652863, + 290.3702702486252, + ], + Array [ + 459.31212368387924, + 289.1060090336526, + ], + Array [ + 458.8535130857379, + 287.6908676516711, + ], + Array [ + 458.74690579161626, + 286.20709418629167, + ], + Array [ + 458.99849782245764, + 284.740925621037, + ], + Array [ + 459.5936666376085, + 283.37757574180716, + ], + Array [ + 460.49782099756845, + 282.19628250763986, + ], + Array [ + 461.65841140845504, + 281.26570273680767, + ], + Array [ + 463.0079843010575, + 280.63992176931447, + ], + Array [ + 464.46810243544826, + 280.3553100243932, + ], + Array [ + 465.9539036770533, + 280.42840915003103, + ], + Array [ + 467.37903318790035, + 280.85497062161136, + ], + Array [ + 468.6606623738596, + 281.61020266636405, ], ] `; @@ -1005,124 +1133,128 @@ Array [ 46.11052040597133, ], Array [ - 14.129612003024915, - 21.803098556727228, + 14.406898944853781, + 21.525811614898366, + ], + Array [ + 13.456662205181654, + 20.202898857344188, ], Array [ - 13.105350408218428, - 20.377128928032562, + 12.978591520873394, + 18.64581939683893, ], Array [ - 12.590037306655162, - 18.698750661993472, + 13.022741018774472, + 17.017599863926556, ], Array [ - 12.637626116098236, - 16.943690406113085, + 13.584488234800315, + 15.488715273511204, ], Array [ - 13.243134275636738, - 15.295703432472994, + 14.605018087146153, + 14.219240245795694, ], Array [ - 14.343164921128356, - 13.927334412239624, + 15.977480830877656, + 13.342089151290704, ], Array [ - 15.822544553610225, - 12.981851943045752, + 17.558179254431163, + 12.949099941136309, ], Array [ - 17.526381735043202, - 12.558248288999108, + 19.181613815596755, + 13.08141868937475, ], Array [ - 19.276284262761916, - 12.700874864498882, + 20.677810487275295, + 13.725191588136706, ], Array [ - 20.88903688018481, - 13.394798629440485, + 21.890117082984474, + 14.813015444982257, ], Array [ - 22.19578396254237, - 14.567365582456453, + 22.691604782135684, + 16.230994814942065, ], Array [ - 23.059708745364023, - 16.095807654038392, + 22.99835761105558, + 17.83066688367114, ], Array [ - 23.39035807583435, - 17.820096555822158, + 22.778258467581374, + 19.444545563301126, ], Array [ - 23.153112881770163, - 19.55969878462292, + 22.054351790135343, + 20.90365733005217, ], Array [ - 22.37281279761663, - 21.132477527874848, + 20.902430798938884, + 22.055232796777343, ], Array [ - 21.131155448163838, - 22.373762435986208, + 19.443101925847895, + 22.77870170812411, ], Array [ - 19.558142685665217, - 23.153590651410333, + 17.829157289100394, + 22.998316678097225, ], Array [ - 17.818469361589404, - 23.390313954137667, + 16.229577318203866, + 22.691083961367784, ], Array [ - 16.0942797321963, - 23.05914735188378, + 14.811838458359269, + 21.889170904478913, ], Array [ - 14.566096906825212, - 22.194764075324144, + 13.724378342439053, + 20.676538016171378, ], Array [ - 13.39392203069359, - 20.88766528168958, + 13.08105433164165, + 19.180148279954956, ], Array [ - 12.700482122756526, - 19.274704559714188, + 12.949222619718594, + 17.556674096220046, ], Array [ - 12.558380524425392, - 17.524759322769086, + 13.342686021708426, + 15.976093640559247, ], Array [ - 12.982495310556633, - 15.821049299103091, + 14.220248815558557, + 14.603894103912967, ], Array [ - 13.928421551086881, - 14.341953377929807, + 15.4900299450988, + 13.583745139993574, ], Array [ - 15.29712051893234, - 13.242333292639481, + 17.01908299087662, + 13.0224566146166, ], Array [ - 16.94528907085815, - 12.637319556433523, + 18.647315695368288, + 12.978795584554788, ], Array [ - 18.70036352440344, - 12.590257267200807, + 20.204251664601827, + 13.457333371181011, ], Array [ - 20.37858712098736, - 13.106073859047239, + 21.526879291607308, + 14.407966941913791, ], Array [ - 21.804249407039563, - 14.130763198644143, + 21.525811614898366, + 14.406898944853781, ], Array [ 46.11052040597133, @@ -1323,56 +1455,212 @@ Array [ exports[`getStrokeOutlinePoints gets stroke outline points with two points: get-stroke-outline-points-two-points 1`] = ` Array [ Array [ - 4.930805185122358, - 197.33938185212202, + 4.893206982421875, + 200, + ], + Array [ + 5.19757506225586, + 171.25, + ], + Array [ + 5.4182419201354985, + 130.28125, + ], + Array [ + 5.578225392098236, + 84.11953125, + ], + Array [ + 5.694213409271221, + 35.75080078125, + ], + Array [ + 5.919621905604509, + 34.375914323509875, + ], + Array [ + 6.572247065536214, + 33.14497884082992, + ], + Array [ + 7.583758862545174, + 32.186873603182136, + ], + Array [ + 8.848251744471371, + 31.60191248186346, + ], + Array [ + 10.233332972783426, + 31.451341060690705, + ], + Array [ + 11.593984177251135, + 31.750924207207646, + ], + Array [ + 12.787744817589694, + 32.469295486891696, + ], + Array [ + 13.689627839633445, + 33.53124123712833, + ], + Array [ + 14.205205852900416, + 34.82557545754132, + ], + Array [ + 14.280497703302178, + 36.21678101358238, + ], + Array [ + 13.907620314226547, + 37.55919831629139, + ], + Array [ + 13.125614046739813, + 38.71227591971099, + ], + Array [ + 12.016355163477442, + 39.55528629438021, + ], + Array [ + 10.695983362332912, + 39.99996603153805, + ], + Array [ + 9.302741919430359, + 39.999757045320045, + ], + Array [ + 7.982503581621712, + 39.554681216638386, + ], + Array [ + 6.8734976513846, + 38.711338102244646, + ], + Array [ + 6.091837342363988, + 37.558025948836814, + ], + Array [ + 5.719362695252612, + 36.215496843321525, + ], + Array [ + 5.795071903926794, + 34.82431393743951, + ], + Array [ + 6.3110381942530545, + 33.53013444867322, + ], + Array [ + 7.213239759432362, + 32.4684593111267, + ], + Array [ + 8.407215857432362, + 31.75044619195609, + ], + Array [ + 9.767956875613374, + 31.451271254275607, + ], + Array [ + 11.1529928701711, + 31.602258193034906, + ], + Array [ + 12.417310206861348, + 32.187598635889216, + ], + Array [ + 13.428534526785299, + 33.14600728395681, + ], + Array [ + 14.08079037670961, + 34.37713849878971, + ], + Array [ + 14.305786396968383, + 35.75209251720783, + ], + Array [ + 14.30578659072878, + 35.75080078125, + ], + Array [ + 14.421774607901764, + 84.11953125, + ], + Array [ + 14.581758079864501, + 130.28125, + ], + Array [ + 14.80242493774414, + 171.25, + ], + Array [ + 15.106793017578125, + 200, + ], + Array [ + 14.958389492516485, + 201.22217370487456, ], Array [ - 6.747974298276899, - 195.28831730319916, + 14.521804137180853, + 202.37331461659824, ], Array [ - 9.310189810502598, - 194.3167098523421, + 13.822411312936213, + 203.3865183712955, ], Array [ - 12.030442387889039, - 194.64715695079116, + 12.900859763588496, + 204.2028975191382, ], Array [ - 14.285516049617891, - 196.20395242542097, + 11.8107101084847, + 204.7750040656963, ], Array [ - 15.558768350206307, - 198.63043093319664, + 10.615321896799927, + 205.06958715160349, ], Array [ - 15.558494325219405, - 201.37068079307463, + 9.384171147562364, + 205.069525594066, ], Array [ - 14.284756754397714, - 203.7969046018623, + 8.188812400163075, + 204.7748229708107, ], Array [ - 12.029371778677488, - 205.35324903062684, + 7.098719961164591, + 204.20260741214784, ], Array [ - 9.309053166276847, - 205.68315207195513, + 6.177250054339279, + 203.38613611323225, ], Array [ - 6.747032026784339, - 204.71103219743117, + 5.4779585539669045, + 202.3728624243187, ], Array [ - 4.930273162880228, - 202.6596042557094, + 5.04148831490518, + 201.22167785981526, ], Array [ - 4.2750001145, - 199.99885500000764, + 4.89320700795584, + 199.9994893206991, ], ] `; diff --git a/packages/perfect-freehand/src/test/__snapshots__/getStrokePoints.spec.ts.snap b/packages/perfect-freehand/src/test/__snapshots__/getStrokePoints.spec.ts.snap index aa41a1d..1784444 100644 --- a/packages/perfect-freehand/src/test/__snapshots__/getStrokePoints.spec.ts.snap +++ b/packages/perfect-freehand/src/test/__snapshots__/getStrokePoints.spec.ts.snap @@ -1499,13 +1499,52 @@ Array [ ], }, Object { - "distance": 114.99999999999999, + "distance": 28.75, "point": Array [ 10, - 85.00000000000001, + 171.25, ], "pressure": 0.5, - "runningLength": 114.99999999999999, + "runningLength": 28.75, + "vector": Array [ + 0, + 1, + ], + }, + Object { + "distance": 40.96875, + "point": Array [ + 10, + 130.28125, + ], + "pressure": 0.5, + "runningLength": 69.71875, + "vector": Array [ + 0, + 1, + ], + }, + Object { + "distance": 46.161718750000006, + "point": Array [ + 10, + 84.11953125, + ], + "pressure": 0.5, + "runningLength": 115.88046875, + "vector": Array [ + 0, + 1, + ], + }, + Object { + "distance": 48.368730468749995, + "point": Array [ + 10, + 35.75080078125, + ], + "pressure": 0.5, + "runningLength": 164.24919921875, "vector": Array [ 0, 1, diff --git a/yarn.lock b/yarn.lock index f1781ee..50b5245 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2316,14 +2316,21 @@ "@babel/runtime" "^7.12.5" "@testing-library/dom" "^8.0.0" -"@tldraw/core@^0.0.94": - version "0.0.94" - resolved "https://registry.yarnpkg.com/@tldraw/core/-/core-0.0.94.tgz#ff86a38496c5fb59aabb53e8e3ed6e14c10e835c" - integrity sha512-Vz/DiIR6AXHQufKgdC7BZdfE5G/xR/WvtQ74HmrkLAOTMCcQT68wNymvMLznHcXQ9jIPJDDqozTl3knzQ55Zpw== +"@tldraw/core@^0.0.107": + version "0.0.107" + resolved "https://registry.yarnpkg.com/@tldraw/core/-/core-0.0.107.tgz#4e148981c760eee75d400757b011d3cf779b50c4" + integrity sha512-X/Y9cJVW3EuBqvDeaX3e0cm/kqm2KkzXpxzja37OvUkoKN821vFudQGjLe5GEsJqo+BcWU6Wm+Yyuj9fM5qrzA== dependencies: - "@tldraw/intersect" "^0.0.94" - "@tldraw/vec" "^0.0.94" - "@use-gesture/react" "^10.0.0-beta.24" + "@tldraw/intersect" "^0.0.107" + "@tldraw/vec" "^0.0.107" + "@use-gesture/react" "^10.0.2" + +"@tldraw/intersect@^0.0.107": + version "0.0.107" + resolved "https://registry.yarnpkg.com/@tldraw/intersect/-/intersect-0.0.107.tgz#4ab800348ecc3dbb26473b38961bc15bdca4e2ce" + integrity sha512-Q3R0Ojil+suWzB6nIOeiLj2nXgqamU1xyd7Q0o+TTsCnmJn6uDc64w7NyhVdhQUmWof58uPfsGNqQAlhv826ZA== + dependencies: + "@tldraw/vec" "^0.0.107" "@tldraw/intersect@^0.0.93": version "0.0.93" @@ -2332,23 +2339,16 @@ dependencies: "@tldraw/vec" "^0.0.93" -"@tldraw/intersect@^0.0.94": - version "0.0.94" - resolved "https://registry.yarnpkg.com/@tldraw/intersect/-/intersect-0.0.94.tgz#3bbfb67c2e999da00354145239af7646e99cf681" - integrity sha512-vClJTxH1gVYY+98N/4lu54jvMn9mgTRJEQ6UQ/BPpvQrBf/6MhKqqlmtVKHTTNoxG8KBtJ2Glvl9Ren8TBj/MA== - dependencies: - "@tldraw/vec" "^0.0.94" +"@tldraw/vec@^0.0.107": + version "0.0.107" + resolved "https://registry.yarnpkg.com/@tldraw/vec/-/vec-0.0.107.tgz#2465eb4d9cb28e63cb79be60226c313a6a5858ce" + integrity sha512-joDeSEMRrSOExg7BjQKqpygIpyUWKlsqnZnU3O0EmsP54aWSk/CoBbbv+kkQf58q5RctV8ESlRxS0sI8mMqxag== "@tldraw/vec@^0.0.93": version "0.0.93" resolved "https://registry.yarnpkg.com/@tldraw/vec/-/vec-0.0.93.tgz#c8f1735cf80c2435dfcb8b328aac413b12205659" integrity sha512-c3Ynt3Z2gvl+52tejD5UBlccS693JOtCvPEcCK8d/H9v7sVUYnvtSyyqmKxjfc2sErGMkCg0XOVRCBIvJZJ7VQ== -"@tldraw/vec@^0.0.94": - version "0.0.94" - resolved "https://registry.yarnpkg.com/@tldraw/vec/-/vec-0.0.94.tgz#8fc7ac6e90e4abb654d9047984d19f5d80c24004" - integrity sha512-IykDaEZXkI1sSul8oZ6xHvZS8kOW60ES0hbYEmnbLbasdI77INDAUGQ/4LZxJ18+1l8kpYgBgnPgkYsZ9ZDNJQ== - "@tootallnate/once@1": version "1.1.2" resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" @@ -2593,17 +2593,17 @@ "@typescript-eslint/types" "4.30.0" eslint-visitor-keys "^2.0.0" -"@use-gesture/core@^10.0.0-beta.25": - version "10.0.0-beta.25" - resolved "https://registry.yarnpkg.com/@use-gesture/core/-/core-10.0.0-beta.25.tgz#4e652cb5ef679bd04a213ef0952d9e95a48960ef" - integrity sha512-of0lh9pMjsps6Xxn9CqLd8dJynpWvqvHMmhcY8HelLopEDAKusCSM2ACrx+gR83hBKjYrmJBXuwfMLUebZFCrA== +"@use-gesture/core@10.0.2": + version "10.0.2" + resolved "https://registry.yarnpkg.com/@use-gesture/core/-/core-10.0.2.tgz#2761144e3b50d5abeffc289e9ef768f0255dd1a6" + integrity sha512-AUtwernZHSFERkdDmXujv7teE0VQKqxLHOC5iC6bj2KIL2fw2wm/bw/7Aw3BN+xavS/qYIB81OiaDw6dJRsTeg== -"@use-gesture/react@^10.0.0-beta.24": - version "10.0.0-beta.25" - resolved "https://registry.yarnpkg.com/@use-gesture/react/-/react-10.0.0-beta.25.tgz#f3034aa4fb539fefec7b44468265238b92a89594" - integrity sha512-bXwlYRP503Tl6iK+WxVH9Tm/S5C7lBSdKWgahEKcV6N0NKqCVkkMqz1Nrbmd51Hrexa4JGpoxNvZ7tzrVDfedw== +"@use-gesture/react@^10.0.2": + version "10.0.2" + resolved "https://registry.yarnpkg.com/@use-gesture/react/-/react-10.0.2.tgz#53edc8a05a42dfa34cc9fb60a959fd7161e8a583" + integrity sha512-eUyEzchj3E+iCU7kBH60g8rinTqBtfskzsR9wMvaJMP9GGdkoloBEjGQMwTpdILGbA9lBI0Y6sqISlH6z1hOYQ== dependencies: - "@use-gesture/core" "^10.0.0-beta.25" + "@use-gesture/core" "10.0.2" "@zkochan/cmd-shim@^3.1.0": version "3.1.0"