diff --git a/client-src/views/draw/components/checkbox/checkbox.module.css b/client-src/views/draw/components/checkbox/checkbox.module.css deleted file mode 100644 index 8ee7842..0000000 --- a/client-src/views/draw/components/checkbox/checkbox.module.css +++ /dev/null @@ -1,51 +0,0 @@ -.root { - position: relative; - flex-grow: 2; - max-width: 200px; - display: flex; - height: 16px; - background: none; - border: none; - cursor: pointer; - padding: 0; -} - -.root:disabled { - opacity: 0.5; -} -.root:disabled::after { - background-color: gainsboro; - opacity: 1; -} - -.root:focus { - outline: none; -} - -.root:focus::after { - border: 2px solid dodgerblue; -} - -.root::after { - content: ""; - position: absolute; - left: 0px; - top: 0px; - bottom: 0px; - width: 16px; - height: 16px; - border: 1px solid gainsboro; - border-radius: 2px; - box-sizing: border-box; -} - -.indicator { - position: initial; - height: 16px; - width: 16px; - border-radius: 2px; - box-sizing: border-box; - background-color: dodgerblue; - border: 1px solid dodgerblue; - z-index: 2; -} diff --git a/client-src/views/draw/components/checkbox/checkbox.tsx b/client-src/views/draw/components/checkbox/checkbox.tsx deleted file mode 100644 index 9c4603d..0000000 --- a/client-src/views/draw/components/checkbox/checkbox.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from "react"; -import * as Label from "@radix-ui/react-label"; -import { - Root, - Indicator, - CheckboxProps as CheckboxOwnProps, -} from "@radix-ui/react-checkbox"; -import styles from "./checkbox.module.css"; - -interface CheckboxProps extends CheckboxOwnProps { - name: string; -} - -export function Checkbox(props: CheckboxProps) { - return ( - <> - - {props.name} - - - - -
- - ); -} diff --git a/client-src/views/draw/components/checkbox/index.ts b/client-src/views/draw/components/checkbox/index.ts deleted file mode 100644 index 057f167..0000000 --- a/client-src/views/draw/components/checkbox/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./checkbox"; diff --git a/client-src/views/draw/components/controls/controls.tsx b/client-src/views/draw/components/controls/controls.tsx index e4b65a5..0cf5427 100644 --- a/client-src/views/draw/components/controls/controls.tsx +++ b/client-src/views/draw/components/controls/controls.tsx @@ -1,10 +1,6 @@ -import * as React from "react"; import { Colors } from "../colors"; -import { Checkbox } from "../checkbox"; import { Slider } from "../slider"; -import styles from "./controls.module.css"; -import { app, useAppState } from "../../state"; -import type { State } from "../../state/state"; +import { app } from "../../state"; import { useControls, COLORS } from "./use-controls"; export function Controls() { diff --git a/client-src/views/draw/components/select/select.module.css b/client-src/views/draw/components/select/select.module.css deleted file mode 100644 index be12048..0000000 --- a/client-src/views/draw/components/select/select.module.css +++ /dev/null @@ -1,25 +0,0 @@ -.select { - grid-column: 2 / span 2; - padding: 0; -} - -.select select { - position: relative; - display: flex; - height: 30px; - width: calc(100% + 6px); - background: none; - border: none; - cursor: pointer; - border-radius: none; - padding: 0; - margin-left: -6px; - outline: none; - font: inherit; - border: 2px solid transparent; -} - -.select select:focus { - outline: none; - border: 2px solid dodgerblue; -} diff --git a/client-src/views/draw/state/corners.json b/client-src/views/draw/state/corners.json deleted file mode 100644 index f17514a..0000000 --- a/client-src/views/draw/state/corners.json +++ /dev/null @@ -1,372 +0,0 @@ -{ - "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] - ] -} diff --git a/client-src/views/draw/state/easings.ts b/client-src/views/draw/state/easings.ts deleted file mode 100644 index 4f026eb..0000000 --- a/client-src/views/draw/state/easings.ts +++ /dev/null @@ -1,62 +0,0 @@ -import type { Easing } from "./types"; - -export const EASINGS: Record number> = { - linear: (t) => t, - easeInQuad: (t) => t * t, - easeOutQuad: (t) => t * (2 - t), - easeInOutQuad: (t) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t), - easeInCubic: (t) => t * t * t, - easeOutCubic: (t) => --t * t * t + 1, - easeInOutCubic: (t) => - t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1, - easeInQuart: (t) => t * t * t * t, - easeOutQuart: (t) => 1 - --t * t * t * t, - easeInOutQuart: (t) => - t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t, - easeInQuint: (t) => t * t * t * t * t, - easeOutQuint: (t) => 1 + --t * t * t * t * t, - easeInOutQuint: (t) => - t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t, - easeInSine: (t) => 1 - Math.cos((t * Math.PI) / 2), - easeOutSine: (t) => Math.sin((t * Math.PI) / 2), - easeInOutSine: (t) => -(Math.cos(Math.PI * t) - 1) / 2, - easeInExpo: (t) => (t <= 0 ? 0 : Math.pow(2, 10 * t - 10)), - easeOutExpo: (t) => (t >= 1 ? 1 : 1 - Math.pow(2, -10 * t)), - easeInOutExpo: (t) => - t <= 0 - ? 0 - : t >= 1 - ? 1 - : t < 0.5 - ? Math.pow(2, 20 * t - 10) / 2 - : (2 - Math.pow(2, -20 * t + 10)) / 2, -}; - -export const EASING_STRINGS: Record = { - linear: `(t) => t`, - easeInQuad: `(t) => t * t`, - easeOutQuad: `(t) => t * (2 - t)`, - easeInOutQuad: `(t) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t)`, - easeInCubic: `(t) => t * t * t`, - easeOutCubic: `(t) => --t * t * t + 1`, - easeInOutCubic: `(t) => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1`, - easeInQuart: `(t) => t * t * t * t`, - easeOutQuart: `(t) => 1 - --t * t * t * t`, - easeInOutQuart: `(t) => t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t`, - easeInQuint: `(t) => t * t * t * t * t`, - easeOutQuint: `(t) => 1 + --t * t * t * t * t`, - easeInOutQuint: `(t) => t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t`, - easeInSine: `(t) => 1 - Math.cos((t * Math.PI) / 2)`, - easeOutSine: `(t) => Math.sin((t * Math.PI) / 2)`, - easeInOutSine: `(t) => -(Math.cos(Math.PI * t) - 1) / 2`, - easeInExpo: `(t) => (t <= 0 ? 0 : Math.pow(2, 10 * t - 10))`, - easeOutExpo: `(t) => (t >= 1 ? 1 : 1 - Math.pow(2, -10 * t))`, - easeInOutExpo: `(t) => - t <= 0 - ? 0 - : t >= 1 - ? 1 - : t < 0.5 - ? Math.pow(2, 20 * t - 10) / 2 - : (2 - Math.pow(2, -20 * t + 10)) / 2`, -}; diff --git a/client-src/views/draw/state/excalidraw.json b/client-src/views/draw/state/excalidraw.json deleted file mode 100644 index 0525dfd..0000000 --- a/client-src/views/draw/state/excalidraw.json +++ /dev/null @@ -1,556 +0,0 @@ -{ - "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" - } -} diff --git a/client-src/views/draw/state/flash.json b/client-src/views/draw/state/flash.json deleted file mode 100644 index e16b322..0000000 --- a/client-src/views/draw/state/flash.json +++ /dev/null @@ -1,137 +0,0 @@ -[ - [0, 49.93, 0.5, 0], - [1, 50.93, 0.5, 0], - [0, 49.71, 0.5, 239], - [0, 49.05, 0.5, 244], - [0, 48.39, 0.5, 246], - [0, 47.25, 0.5, 258], - [0, 46.59, 0.5, 263], - [0, 45.45, 0.5, 271], - [0, 44.79, 0.5, 279], - [0, 43.66, 0.5, 287], - [0.75, 42.52, 0.5, 295], - [1.62, 40.78, 0.5, 303], - [2.48, 39.05, 0.5, 312], - [3.46, 36.61, 0.5, 320], - [4.92, 34.65, 0.5, 328], - [5.89, 32.21, 0.5, 336], - [6.86, 29.77, 0.5, 344], - [8.32, 27.33, 0.5, 352], - [9.19, 25.59, 0.5, 360], - [9.57, 24.45, 0.5, 368], - [10.33, 23.3, 0.5, 377], - [10.7, 22.16, 0.5, 384], - [11.03, 21.51, 0.5, 393], - [11.3, 21.23, 0.5, 401], - [11.63, 20.57, 0.5, 409], - [11.9, 20.3, 0.5, 417], - [12.22, 19.64, 0.5, 426], - [12.98, 18.5, 0.5, 433], - [13.74, 17.35, 0.5, 443], - [14.61, 15.61, 0.5, 450], - [15.36, 14.47, 0.5, 460], - [16.66, 13.16, 0.5, 466], - [18.12, 11.22, 0.5, 476], - [18.88, 10.07, 0.5, 483], - [20.18, 8.77, 0.5, 493], - [20.83, 8.11, 0.5, 499], - [22.13, 6.81, 0.5, 509], - [22.79, 6.15, 0.5, 515], - [23.93, 5.39, 0.5, 526], - [25.07, 4.63, 0.5, 531], - [26.21, 3.87, 0.5, 542], - [26.86, 3.21, 0.5, 547], - [27.98, 2.46, 0.5, 559], - [29.12, 1.7, 0.5, 563], - [29.77, 1.37, 0.5, 579], - [30.43, 1.04, 0.5, 581], - [31.08, 0.71, 0.5, 591], - [31.35, 0.71, 0.5, 596], - [32, 0.39, 0.5, 608], - [33.14, 0.39, 0.5, 612], - [34.28, 0.39, 0.5, 620], - [35.42, 0, 0.5, 629], - [37.160000000000025, 0, 0.5, 637], - [38.30000000000001, 0, 0.5, 645], - [40.00999999999999, 0, 0.5, 654], - [41.75, 0, 0.5, 661], - [42.889999999999986, 0, 0.5, 670], - [44.620000000000005, 0, 0.5, 678], - [45.26999999999998, 0, 0.5, 686], - [46.410000000000025, 0, 0.5, 694], - [46.68000000000001, 0, 0.5, 702], - [47.34000000000003, 0, 0.5, 710], - [47.610000000000014, 0, 0.5, 719], - [47.879999999999995, 0, 0.5, 726], - [48.53000000000003, 0, 0.5, 735], - [48.81, 0, 0.5, 743], - [49.079999999999984, 0, 0.5, 750], - [49.35000000000002, 0, 0.5, 759], - [49.629999999999995, 0, 0.5, 768], - [49.900000000000034, 0, 0.5, 776], - [50.170000000000016, 0, 0.5, 784], - [50.44999999999999, 0.2799999999999727, 0.5, 793], - [50.44999999999999, 0.5500000000000114, 0.5, 800], - [50.72000000000003, 0.5500000000000114, 0.5, 810], - [50.72000000000003, 0.8199999999999932, 0.5, 816], - [50.99000000000001, 1.089999999999975, 0.5, 827], - [51.24000000000001, 1.339999999999975, 0.5, 843], - [51.24000000000001, 1.6100000000000136, 0.5, 848], - [51.50999999999999, 1.8899999999999864, 0.5, 860], - [51.79000000000002, 2.159999999999968, 0.5, 864], - [51.79000000000002, 2.430000000000007, 0.5, 876], - [51.79000000000002, 3.089999999999975, 0.5, 881], - [52.06, 3.3600000000000136, 0.5, 893], - [52.06, 3.6299999999999955, 0.5, 897], - [52.06, 4.279999999999973, 0.5, 909], - [52.329999999999984, 4.560000000000002, 0.5, 913], - [52.329999999999984, 4.829999999999984, 0.5, 926], - [52.329999999999984, 5.110000000000014, 0.5, 929], - [52.329999999999984, 5.3799999999999955, 0.5, 942], - [52.329999999999984, 5.649999999999977, 0.5, 946], - [52.329999999999984, 5.930000000000007, 0.5, 959], - [52.329999999999984, 6.199999999999989, 0.5, 962], - [52.329999999999984, 6.46999999999997, 0.5, 975], - [52.329999999999984, 6.75, 0.5, 979], - [52.329999999999984, 7.399999999999977, 0.5, 987], - [52.329999999999984, 8.050000000000011, 0.5, 995], - [52.329999999999984, 8.699999999999989, 0.5, 1003], - [52.329999999999984, 10.430000000000007, 0.5, 1011], - [52.329999999999984, 11.569999999999993, 0.5, 1019], - [52.329999999999984, 13.300000000000011, 0.5, 1027], - [52.329999999999984, 15.04000000000002, 0.5, 1035], - [52.329999999999984, 16.769999999999982, 0.5, 1044], - [52.329999999999984, 17.909999999999968, 0.5, 1052], - [51.94999999999999, 19.05000000000001, 0.5, 1060], - [51.94999999999999, 20.19999999999999, 0.5, 1068], - [51.56999999999999, 21.339999999999975, 0.5, 1077], - [51.24000000000001, 21.99000000000001, 0.5, 1084], - [51.24000000000001, 22.639999999999986, 0.5, 1096], - [51.24000000000001, 22.909999999999968, 0.5, 1101], - [50.910000000000025, 23.569999999999993, 0.5, 1109], - [50.910000000000025, 23.839999999999975, 0.5, 1117], - [50.910000000000025, 24.110000000000014, 0.5, 1126], - [50.629999999999995, 24.389999999999986, 0.5, 1133], - [50.629999999999995, 25.04000000000002, 0.5, 1142], - [50.360000000000014, 25.310000000000002, 0.5, 1149], - [50.360000000000014, 25.95999999999998, 0.5, 1160], - [50.03000000000003, 26.620000000000005, 0.5, 1166], - [49.69999999999999, 27.269999999999982, 0.5, 1176], - [49.370000000000005, 27.920000000000016, 0.5, 1182], - [49.370000000000005, 28.19999999999999, 0.5, 1193], - [48.99000000000001, 29.339999999999975, 0.5, 1198], - [48.660000000000025, 29.99000000000001, 0.5, 1209], - [48.660000000000025, 30.639999999999986, 0.5, 1214], - [48.329999999999984, 31.29000000000002, 0.5, 1226], - [48.329999999999984, 31.94999999999999, 0.5, 1231], - [48, 32.599999999999966, 0.5, 1243], - [48, 32.870000000000005, 0.5, 1246], - [47.68000000000001, 33.51999999999998, 0.5, 1260], - [47.68000000000001, 33.80000000000001, 0.5, 1263], - [47.68000000000001, 34.06999999999999, 0.5, 1276], - [47.68000000000001, 34.30000000000001, 0.5, 1297], - [47.68000000000001, 34.52999999999997, 0.5, 1355], - [47.400000000000034, 34.52999999999997, 0.5, 1361], - [47.400000000000034, 34.75999999999999, 0.5, 1437], - [47.170000000000016, 34.75999999999999, 0.5, 1493] -] diff --git a/client-src/views/draw/state/sample.json b/client-src/views/draw/state/sample.json deleted file mode 100644 index b35a6b4..0000000 --- a/client-src/views/draw/state/sample.json +++ /dev/null @@ -1,362 +0,0 @@ -[ - [23.96, 77.14, 0.5, 0], - [23.96, 77.14, 0.5, 0], - [24.64, 77.14, 0.5, 177], - [27.03, 77.14, 0.5, 181], - [28.77, 77.14, 0.5, 187], - [29.91, 77.14, 0.5, 195], - [35.09, 77.14, 0.5, 210], - [35.75, 77.14, 0.5, 211], - [40.93, 77.14, 0.5, 219], - [45.1, 77.14, 0.5, 228], - [47.53, 77.14, 0.5, 239], - [51.7, 77.14, 0.5, 244], - [55.86, 76.54, 0.5, 254], - [61.05, 74.59, 0.5, 260], - [65.21, 72.81, 0.5, 270], - [67.16, 71.34, 0.5, 276], - [71.28, 70.16, 0.5, 287], - [74.85, 67.78, 0.5, 293], - [79.39, 64.53, 0.5, 303], - [82.96, 62.15, 0.5, 309], - [87.87, 57.94, 0.5, 319], - [89.33, 55.98, 0.5, 326], - [92.3, 53.01, 0.5, 336], - [95.78, 47.43, 0.5, 342], - [98.16, 43.86, 0.5, 353], - [99.03, 42.12, 0.5, 358], - [100.81, 37.95, 0.5, 370], - [101.89, 34.72, 0.5, 374], - [102.97, 31.47, 0.5, 386], - [103.51, 28.22, 0.5, 390], - [104.04, 25.03, 0.5, 403], - [104.04, 22.59, 0.5, 406], - [104.04, 20.15, 0.5, 420], - [104.04, 17.71, 0.5, 422], - [104.04, 14.51, 0.5, 435], - [102.59, 12.57, 0.5, 440], - [101.61, 10.13, 0.5, 448], - [100.15, 7.69, 0.5, 456], - [98.71, 5.77, 0.5, 467], - [97.4, 4.46, 0.5, 472], - [96.64, 3.32, 0.5, 480], - [95.5, 2.56, 0.5, 488], - [94.74, 1.42, 0.5, 496], - [93.6, 1.04, 0.5, 505], - [92.94, 0.71, 0.5, 513], - [91.8, 0.33, 0.5, 521], - [91.14, 0, 0.5, 529], - [90.49, 0, 0.5, 537], - [89.34, 0, 0.5, 545], - [88.69, 0, 0.5, 553], - [87.55, 0, 0.5, 562], - [86.89, 0, 0.5, 570], - [85.75, 0, 0.5, 578], - [84.44, 1.3, 0.5, 586], - [82.98, 3.25, 0.5, 594], - [82.11, 4.99, 0.5, 603], - [80.64, 7.42, 0.5, 610], - [79.18, 9.37, 0.5, 619], - [77.71, 11.81, 0.5, 626], - [76.25, 14.25, 0.5, 636], - [74.78, 16.69, 0.5, 642], - [72.86, 18.61, 0.5, 653], - [71.77, 21.86, 0.5, 659], - [70.3, 24.29, 0.5, 670], - [68.52, 28.46, 0.5, 674], - [67.33, 32.62, 0.5, 686], - [66.68, 37.81, 0.5, 691], - [66.02, 43, 0.5, 703], - [65.37, 48.19, 0.5, 707], - [65.37, 54.51, 0.5, 720], - [65.37, 60.83, 0.5, 723], - [65.37, 67.15, 0.5, 736], - [65.37, 73.47, 0.5, 740], - [65.37, 80.86, 0.5, 753], - [65.37, 89.77, 0.5, 756], - [65.37, 98.69, 0.5, 764], - [64.56, 107.6, 0.5, 772], - [64.56, 117.94, 0.5, 783], - [63.69, 128.26, 0.5, 789], - [63.69, 149.68, 0.5, 796], - [62.67, 165.09, 0.5, 805], - [61.91, 172.65, 0.5, 812], - [60.93, 186.27, 0.5, 821], - [60.01, 198.2, 0.5, 829], - [59.09, 210.14, 0.5, 837], - [57.36, 220.51, 0.5, 845], - [56.6, 228.08, 0.5, 853], - [54.33, 235.64, 0.5, 861], - [52.95, 241.86, 0.5, 870], - [50.35, 247.04, 0.5, 878], - [47.75, 252.23, 0.5, 886], - [44.78, 255.8, 0.5, 894], - [40.93, 259.64, 0.5, 903], - [38.98, 261.1, 0.5, 911], - [36.27, 263.26, 0.5, 919], - [33.06, 264.87, 0.5, 927], - [30.62, 265.84, 0.5, 936], - [25.43, 266.49, 0.5, 943], - [22.18, 266.49, 0.5, 954], - [18.93, 266.49, 0.5, 959], - [16.22, 264.32, 0.5, 970], - [12.97, 259.78, 0.5, 975], - [9.73, 255.24, 0.5, 987], - [8.27, 252.8, 0.5, 992], - [5.67, 248.26, 0.5, 1003], - [3.88, 244.1, 0.5, 1009], - [2.1, 239.93, 0.5, 1020], - [0.58, 232.36, 0.5, 1024], - [0, 228.28, 0.5, 1037], - [0, 224.11, 0.5, 1040], - [0, 218.92000000000002, 0.5, 1054], - [0, 214.76, 0.5, 1057], - [1.1800000000000068, 210.58999999999997, 0.5, 1070], - [2.9600000000000364, 206.42000000000002, 0.5, 1073], - [6.210000000000036, 201.88, 0.5, 1085], - [9.180000000000007, 198.31, 0.5, 1089], - [13.069999999999993, 194.41000000000003, 0.5, 1103], - [18.689999999999998, 190.89999999999998, 0.5, 1105], - [24.30000000000001, 187.38, 0.5, 1113], - [30.620000000000005, 184.57, 0.5, 1122], - [36.94, 181.76, 0.5, 1130], - [43.75, 177.97000000000003, 0.5, 1138], - [51.31, 174.94, 0.5, 1146], - [58.120000000000005, 171.16000000000003, 0.5, 1155], - [66.22000000000003, 166.29000000000002, 0.5, 1163], - [73.02000000000004, 161.76, 0.5, 1171], - [80.26999999999998, 156.11, 0.5, 1179], - [87.57000000000005, 150.44, 0.5, 1187], - [94.00999999999999, 143.99, 0.5, 1195], - [100.49000000000001, 137.51, 0.5, 1203], - [104.96000000000004, 131.54000000000002, 0.5, 1212], - [109.5, 125.49000000000001, 0.5, 1220], - [114.02999999999997, 118.68, 0.5, 1228], - [116.62, 113.49000000000001, 0.5, 1237], - [119.43000000000006, 107.16, 0.5, 1244], - [121.53999999999996, 100.84, 0.5, 1253], - [123.63, 94.56, 0.5, 1261], - [124.11000000000001, 92.11000000000001, 0.5, 1270], - [124.71000000000004, 87.94999999999999, 0.5, 1277], - [125.25, 84.69999999999999, 0.5, 1286], - [125.72000000000003, 82.28999999999999, 0.5, 1293], - [126.15999999999997, 80.56, 0.5, 1303], - [126.15999999999997, 79.9, 0.5, 1309], - [126.15999999999997, 79.25, 0.5, 1320], - [126.15999999999997, 78.97, 0.5, 1325], - [126.15999999999997, 78.69, 0.5, 1336], - [126.15999999999997, 78.44, 0.5, 1353], - [126.15999999999997, 79.42000000000002, 0.5, 1423], - [126.15999999999997, 82.67000000000002, 0.5, 1431], - [126.15999999999997, 86.83000000000001, 0.5, 1439], - [126.15999999999997, 90.99000000000001, 0.5, 1448], - [125.5, 96.18, 0.5, 1455], - [124.86000000000001, 101.34, 0.5, 1463], - [124.14999999999998, 107.66, 0.5, 1472], - [123.48000000000002, 113.72, 0.5, 1480], - [123.48000000000002, 120.03999999999999, 0.5, 1488], - [122.65999999999997, 128.95, 0.5, 1496], - [122.65999999999997, 136.51999999999998, 0.5, 1504], - [122.65999999999997, 144.07999999999998, 0.5, 1512], - [121.90999999999997, 151.64, 0.5, 1521], - [121.90999999999997, 159.2, 0.5, 1529], - [121.90999999999997, 168.11, 0.5, 1537], - [121.90999999999997, 177.01999999999998, 0.5, 1545], - [121.90999999999997, 184.58999999999997, 0.5, 1553], - [121.90999999999997, 187.82999999999998, 0.5, 1561], - [121.90999999999997, 193.01999999999998, 0.5, 1570], - [121.90999999999997, 196.26999999999998, 0.5, 1578], - [121.90999999999997, 198.7, 0.5, 1586], - [121.90999999999997, 200.44, 0.5, 1594], - [121.90999999999997, 202.17000000000002, 0.5, 1605], - [121.90999999999997, 202.82999999999998, 0.5, 1610], - [122.56000000000006, 203.48000000000002, 0.5, 1621], - [123.70000000000005, 203.86, 0.5, 1626], - [125.43000000000006, 204.29000000000002, 0.5, 1638], - [128.68000000000006, 204.29000000000002, 0.5, 1643], - [131.93000000000006, 204.29000000000002, 0.5, 1654], - [136.08000000000004, 204.29000000000002, 0.5, 1659], - [140.25, 202.51, 0.5, 1670], - [144.77999999999997, 199.91000000000003, 0.5, 1676], - [149.32000000000005, 196.66000000000003, 0.5, 1687], - [155.37, 192.12, 0.5, 1691], - [160.28999999999996, 187.2, 0.5, 1703], - [165.18000000000006, 182.31, 0.5, 1707], - [170.10000000000002, 177.39, 0.5, 1720], - [174.62, 171.36, 0.5, 1724], - [179.14999999999998, 164.55, 0.5, 1736], - [183.69000000000005, 158.49, 0.5, 1739], - [187.46000000000004, 151.69, 0.5, 1753], - [188.93000000000006, 149.25, 0.5, 1756], - [190.86, 144.07, 0.5, 1769], - [192.81000000000006, 138.88, 0.5, 1772], - [193.35000000000002, 135.63, 0.5, 1785], - [194.10000000000002, 128.06, 0.5, 1789], - [194.10000000000002, 124.81, 0.5, 1796], - [194.10000000000002, 123.67000000000002, 0.5, 1805], - [193.45000000000005, 118.47999999999999, 0.5, 1813], - [191.98000000000002, 116.52000000000001, 0.5, 1821], - [190.51999999999998, 114.57, 0.5, 1829], - [188.57000000000005, 112.62, 0.5, 1838], - [187.26999999999998, 111.32, 0.5, 1846], - [185.96000000000004, 110.02000000000001, 0.5, 1854], - [185.31000000000006, 109.36000000000001, 0.5, 1861], - [184.64999999999998, 109.03, 0.5, 1870], - [184, 108.69999999999999, 0.5, 1878], - [183.72000000000003, 108.69999999999999, 0.5, 1886], - [183.06000000000006, 108.69999999999999, 0.5, 1894], - [182.40999999999997, 108.69999999999999, 0.5, 1903], - [180.67000000000007, 108.69999999999999, 0.5, 1911], - [179.36, 110.00999999999999, 0.5, 1921], - [177.45000000000005, 111.92000000000002, 0.5, 1927], - [175.98000000000002, 113.86000000000001, 0.5, 1937], - [174.02999999999997, 115.81, 0.5, 1944], - [172.57000000000005, 118.25, 0.5, 1954], - [171.11, 120.67000000000002, 0.5, 1960], - [168.51, 126.36000000000001, 0.5, 1977], - [167.21000000000004, 131.54000000000002, 0.5, 1987], - [166.61, 135.68, 0.5, 1992], - [166.61, 138.92000000000002, 0.5, 2004], - [166.61, 143.04000000000002, 0.5, 2009], - [166.61, 148.23000000000002, 0.5, 2021], - [166.61, 149.95999999999998, 0.5, 2024], - [167.28999999999996, 156.11, 0.5, 2037], - [168.26999999999998, 158.54000000000002, 0.5, 2040], - [171.96000000000004, 165.19, 0.5, 2054], - [174.34000000000003, 168.76, 0.5, 2057], - [175.20000000000005, 170.49, 0.5, 2070], - [179.74, 176.54000000000002, 0.5, 2073], - [181.03999999999996, 177.83999999999997, 0.5, 2087], - [184.01, 180.81, 0.5, 2089], - [186.71000000000004, 182.98000000000002, 0.5, 2103], - [190.88, 184.76, 0.5, 2106], - [194.12, 185.3, 0.5, 2114], - [197.37, 185.3, 0.5, 2122], - [200.58000000000004, 185.3, 0.5, 2130], - [204.74, 185.3, 0.5, 2138], - [208.31000000000006, 182.92000000000002, 0.5, 2147], - [211.87, 179.94, 0.5, 2155], - [214.85000000000002, 176.37, 0.5, 2163], - [219.06000000000006, 171.45, 0.5, 2171], - [222.57000000000005, 165.82999999999998, 0.5, 2179], - [225.15999999999997, 160.64, 0.5, 2187], - [228.19000000000005, 153.07, 0.5, 2195], - [231, 146.75, 0.5, 2204], - [232.05000000000007, 143.56, 0.5, 2212], - [233.35000000000002, 138.37, 0.5, 2220], - [234.64999999999998, 133.18, 0.5, 2228], - [235.24, 129.01, 0.5, 2237], - [235.73000000000002, 126.57, 0.5, 2245], - [236.21000000000004, 124.13, 0.5, 2254], - [236.21000000000004, 122.39000000000001, 0.5, 2261], - [236.21000000000004, 121.25, 0.5, 2271], - [236.21000000000004, 120.1, 0.5, 2277], - [236.21000000000004, 119.44999999999999, 0.5, 2287], - [236.21000000000004, 119.17000000000002, 0.5, 2294], - [236.21000000000004, 118.89000000000001, 0.5, 2305], - [236.21000000000004, 118.64000000000001, 0.5, 2321], - [236.21000000000004, 118.87, 0.5, 2367], - [236.21000000000004, 120.58000000000001, 0.5, 2375], - [236.21000000000004, 123.82999999999998, 0.5, 2383], - [236.21000000000004, 127.99000000000001, 0.5, 2390], - [236.21000000000004, 133.18, 0.5, 2404], - [236.21000000000004, 139.45, 0.5, 2407], - [236.86, 144.64, 0.5, 2420], - [237.39999999999998, 147.89, 0.5, 2423], - [237.98000000000002, 152.01, 0.5, 2436], - [239.76999999999998, 156.17000000000002, 0.5, 2439], - [240.85000000000002, 159.42000000000002, 0.5, 2453], - [242.47000000000003, 162.66000000000003, 0.5, 2455], - [244.42000000000007, 164.61, 0.5, 2468], - [245.88, 166.56, 0.5, 2472], - [247.83000000000004, 168.01999999999998, 0.5, 2480], - [249.56000000000006, 168.89, 0.5, 2488], - [252, 169.37, 0.5, 2496], - [253.73000000000002, 169.81, 0.5, 2504], - [256.1700000000001, 169.81, 0.5, 2512], - [259.4200000000001, 169.81, 0.5, 2521], - [261.15, 169.81, 0.5, 2529], - [263.1, 167.85000000000002, 0.5, 2537], - [265.48, 164.28000000000003, 0.5, 2545], - [267.26, 160.11, 0.5, 2553], - [268.64, 153.88, 0.5, 2562], - [270.05000000000007, 147.56, 0.5, 2570], - [270.73, 141.38, 0.5, 2578], - [271.27, 138.13, 0.5, 2586], - [271.27, 131.81, 0.5, 2594], - [271.27, 127.67000000000002, 0.5, 2603], - [271.27, 124.42000000000002, 0.5, 2610], - [271.27, 121.97, 0.5, 2620], - [271.27, 120.24000000000001, 0.5, 2626], - [271.27, 119.1, 0.5, 2637], - [271.27, 118.82, 0.5, 2642], - [271.27, 118.53999999999999, 0.5, 2652], - [271.27, 118.25999999999999, 0.5, 2659], - [271.49, 118.25999999999999, 0.5, 2742], - [272.46000000000004, 120.69999999999999, 0.5, 2750], - [273.93000000000006, 122.65, 0.5, 2757], - [276.30000000000007, 126.20999999999998, 0.5, 2772], - [278.89, 130.75, 0.5, 2775], - [281.44000000000005, 135.2, 0.5, 2790], - [284.03, 139.74, 0.5, 2792], - [287.53999999999996, 145.36, 0.5, 2797], - [291.05000000000007, 150.98000000000002, 0.5, 2805], - [293.65, 155.51999999999998, 0.5, 2814], - [296.24, 160.7, 0.5, 2822], - [299.05000000000007, 167.01999999999998, 0.5, 2829], - [301.86, 173.35000000000002, 0.5, 2838], - [304.12, 180.91000000000003, 0.5, 2846], - [306.55000000000007, 189.82, 0.5, 2854], - [308.1700000000001, 198.73000000000002, 0.5, 2862], - [309.78999999999996, 207.64, 0.5, 2870], - [311.40999999999997, 216.55, 0.5, 2878], - [312.15999999999997, 224.11, 0.5, 2887], - [312.97, 233.01999999999998, 0.5, 2895], - [313.78, 241.93, 0.5, 2903], - [313.78, 248.25, 0.5, 2911], - [313.78, 251.5, 0.5, 2920], - [313.78, 260.39, 0.5, 2928], - [313.28999999999996, 262.83, 0.5, 2935], - [310.81000000000006, 267.78000000000003, 0.5, 2945], - [306.27, 271.02, 0.5, 2953], - [302.69000000000005, 273.4, 0.5, 2960], - [296.37, 274.8, 0.5, 2970], - [291.18000000000006, 275.45, 0.5, 2977], - [284.86, 275.45, 0.5, 2987], - [282.43000000000006, 275.45, 0.5, 2994], - [278.26, 275.45, 0.5, 3003], - [275.82000000000005, 274.47, 0.5, 3009], - [271.27, 271.23, 0.5, 3021], - [269.81000000000006, 268.79, 0.5, 3026], - [268.62, 264.62, 0.5, 3038], - [268.62, 261.37, 0.5, 3041], - [268.62, 257.2, 0.5, 3053], - [268.62, 252.01, 0.5, 3058], - [269.32000000000005, 245.69, 0.5, 3070], - [275.15, 233.04000000000002, 0.5, 3073], - [280.65999999999997, 222.01, 0.5, 3087], - [287.85, 207.63, 0.5, 3090], - [295.03, 193.25, 0.5, 3103], - [303.49, 178.45, 0.5, 3107], - [307.53999999999996, 170.33999999999997, 0.5, 3120], - [315.76, 156.99, 0.5, 3123], - [324.40999999999997, 141.83999999999997, 0.5, 3135], - [332.62, 128.49, 0.5, 3139], - [338.05000000000007, 117.61000000000001, 0.5, 3147], - [341.28999999999996, 108.69999999999999, 0.5, 3155], - [344.53, 99.78999999999999, 0.5, 3163], - [345.23, 93.46000000000001, 0.5, 3172], - [345.98, 85.9, 0.5, 3179], - [345.98, 79.57, 0.5, 3188], - [345.98, 74.38, 0.5, 3196], - [342.47, 68.75999999999999, 0.5, 3204], - [341, 66.81, 0.5, 3212], - [338.03, 63.83000000000001, 0.5, 3220], - [335.90999999999997, 61.19, 0.5, 3229], - [334.61, 59.879999999999995, 0.5, 3236], - [333.30000000000007, 58.58000000000001, 0.5, 3245], - [332.64, 58.25, 0.5, 3253], - [331.99, 57.59, 0.5, 3262], - [331.71000000000004, 57.59, 0.5, 3269], - [331.43000000000006, 57.31, 0.5, 3277] -] diff --git a/client-src/views/draw/state/shapes/draw.tsx b/client-src/views/draw/state/shapes/draw.tsx index 0f51aae..9e1c6db 100644 --- a/client-src/views/draw/state/shapes/draw.tsx +++ b/client-src/views/draw/state/shapes/draw.tsx @@ -13,7 +13,6 @@ import { import { Vec } from "@tldraw/vec"; import { getStroke } from "perfect-freehand"; import type { DrawShape } from "../types"; -import { EASINGS } from "../easings"; type T = DrawShape; type E = SVGSVGElement; @@ -69,13 +68,10 @@ export class DrawUtil extends TLShapeUtil { strokeWidth, streamline, smoothing, - easing, taperStart, taperEnd, capStart, capEnd, - easingEnd, - easingStart, stroke, fill, isFilled, @@ -90,17 +86,17 @@ export class DrawUtil extends TLShapeUtil { size, thinning, streamline, - easing: EASINGS[easing], + easing: (t) => t, smoothing, start: { taper: taperStart, cap: capStart, - easing: EASINGS[easingStart], + easing: (t) => t, }, end: { taper: taperEnd, cap: capEnd, - easing: EASINGS[easingEnd], + easing: (t) => t, }, simulatePressure, last: isDone, @@ -275,12 +271,4 @@ export function getSvgPathFromStroke( return result; } -export function dot([x, y]: number[]) { - return `M ${x - 0.5},${y} a .5,.5 0 1,0 1,0 a .5,.5 0 1,0 -1,0`; -} - -export function dots(points: number[][]) { - return points.map(dot).join(" "); -} - export const draw = new DrawUtil(); diff --git a/client-src/views/draw/state/state.ts b/client-src/views/draw/state/state.ts index d49a825..9cadd07 100644 --- a/client-src/views/draw/state/state.ts +++ b/client-src/views/draw/state/state.ts @@ -1,16 +1,11 @@ import * as React from "react"; import type { Doc, DrawShape, DrawStyles, State } from "./types"; -import { - TLPointerEventHandler, - TLShapeUtilsMap, - Utils, -} from "@tldraw/core"; +import { TLPointerEventHandler, TLShapeUtilsMap, Utils } from "@tldraw/core"; import { Vec } from "@tldraw/vec"; import { StateManager } from "rko"; import { draw, DrawUtil } from "./shapes"; import sample from "./sample.json"; import type { StateSelector } from "zustand"; -import { copyTextToClipboard, pointInPolygon } from "./utils"; export const shapeUtils: TLShapeUtilsMap = { draw: new DrawUtil(), @@ -65,11 +60,6 @@ export class AppState extends StateManager { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore window["app"] = this; - - if (Object.values(this.state.page.shapes).length === 0) { - this.addShape({ id: "sample", points: sample }); - this.centerShape("sample"); - } }; cleanup = (state: State) => { @@ -178,10 +168,7 @@ export class AppState extends StateManager { const camera = state.pageState.camera; const newPoint = [ - ...Vec.sub( - Vec.round(Vec.sub(point, camera.point)), - shape.point, - ), + ...Vec.sub(Vec.round(Vec.sub(point, camera.point)), shape.point), pressure, Date.now() - currentStroke.startTime, ]; @@ -268,98 +255,6 @@ export class AppState extends StateManager { }); }; - replayShape = (points: number[][]) => { - const newShape = draw.create({ - id: Utils.uniqueId(), - parentId: "page", - childIndex: 1, - point: [0, 0], - points: [], - style: this.state.appState.style, - }); - - this.patchState({ - page: { - shapes: { - [newShape.id]: newShape, - }, - }, - }); - - this.centerShape(newShape.id); - - points - .map((pt, i) => [...Vec.sub(pt, newShape.point), pt[2], pt[3] || i * 10]) - .forEach((pt, i) => { - setTimeout(() => { - this.patchState({ - page: { - shapes: { - [newShape.id]: { - points: points.slice(0, i), - }, - }, - }, - }); - }, pt[3] * 20); - }); - }; - - addShape = (shape: Partial) => { - const newShape = draw.create({ - id: Utils.uniqueId(), - parentId: "page", - childIndex: 1, - point: [0, 0], - points: [], - style: this.state.appState.style, - ...shape, - }); - - const bounds = Utils.getBoundsFromPoints(newShape.points); - - const topLeft = [bounds.minX, bounds.minY]; - - newShape.points = newShape.points.map((pt, i) => - Vec.sub(pt, topLeft).concat(pt[2] || 0.5, pt[3] || i * 10), - ); - - this.patchState({ - page: { - shapes: { - [newShape.id]: newShape, - }, - }, - }); - - this.persist(); - - return newShape; - }; - - - - startStyleUpdate = () => { - return this.setSnapshot(); - }; - - patchStyleForAllShapes = (style: Partial) => { - const { shapes } = this.state.page; - - return this.patchState({ - appState: { - style, - }, - page: { - shapes: { - ...Object.fromEntries( - Object.keys(shapes).map((id) => [id, { style }]), - ), - }, - }, - }); - }; - patchStyle = (style: Partial) => { return this.patchState({ appState: { @@ -389,128 +284,6 @@ export class AppState extends StateManager { }); }; - setNextStyleForAllShapes = (style: Partial) => { - const { shapes } = this.state.page; - - return this.setState({ - before: { - appState: { - style: Object.fromEntries( - Object.keys(style).map((key) => [ - key, - this.state.appState.style[key as keyof DrawStyles], - ]), - ), - }, - page: { - shapes: { - ...Object.fromEntries( - Object.entries(shapes).map(([id, shape]) => [ - id, - { - style: Object.fromEntries( - Object.keys(style).map((key) => [ - key, - shape.style[key as keyof DrawStyles], - ]), - ), - }, - ]), - ), - }, - }, - }, - after: { - appState: { - style, - }, - page: { - shapes: { - ...Object.fromEntries( - Object.keys(shapes).map((id) => [id, { style }]), - ), - }, - }, - }, - }); - }; - - resetStyle = (prop: keyof DrawStyles) => { - const { shapes } = this.state.page; - const { state } = this; - - const initialStyle = initialState.appState.style[prop]; - - return this.setState({ - before: { - appState: state.appState, - page: { - shapes: { - ...Object.fromEntries( - Object.entries(shapes).map(([id, shape]) => [ - id, - { - style: { [prop]: shape.style[prop] }, - }, - ]), - ), - }, - }, - }, - after: { - appState: { - style: { [prop]: initialStyle }, - }, - page: { - shapes: { - ...Object.fromEntries( - Object.keys(shapes).map((id) => [id, { [prop]: initialStyle }]), - ), - }, - }, - }, - }); - }; - - resetStyles = () => { - const { shapes } = this.state.page; - const { state } = this; - - const currentAppState = state.appState; - const initialAppState = initialState.appState; - - return this.setState({ - before: { - appState: currentAppState, - page: { - shapes: { - ...Object.fromEntries( - Object.keys(shapes).map((id) => [ - id, - { - style: currentAppState.style, - }, - ]), - ), - }, - }, - }, - after: { - appState: initialAppState, - page: { - shapes: { - ...Object.fromEntries( - Object.keys(shapes).map((id) => [ - id, - { style: initialAppState.style }, - ]), - ), - }, - }, - }, - }); - }; - copySvg = () => { const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); @@ -609,14 +382,6 @@ export class AppState extends StateManager { }, }); }; - - selectDrawingTool = () => { - this.patchState({ - appState: { - tool: "drawing", - }, - }); - }; } export const app = new AppState( diff --git a/client-src/views/draw/state/types.ts b/client-src/views/draw/state/types.ts index 79858a8..329d5ff 100644 --- a/client-src/views/draw/state/types.ts +++ b/client-src/views/draw/state/types.ts @@ -1,17 +1,7 @@ import type { TLBinding, TLPage, TLPageState, TLShape } from "@tldraw/core"; -export type Entries = { - [K in keyof T]: [K, T[K]]; -}[keyof T][]; - export type Patch = Partial<{ [P in keyof T]: Patch }>; -export type Command = { - id: string; - before: Patch; - after: Patch; -}; - export interface DrawStyles { size: number; fill: string; @@ -52,24 +42,3 @@ export interface Data extends State { undo: () => void; redo: () => void; } - -export type Easing = - | "linear" - | "easeInQuad" - | "easeOutQuad" - | "easeInOutQuad" - | "easeInCubic" - | "easeOutCubic" - | "easeInOutCubic" - | "easeInQuart" - | "easeOutQuart" - | "easeInOutQuart" - | "easeInQuint" - | "easeOutQuint" - | "easeInOutQuint" - | "easeInSine" - | "easeOutSine" - | "easeInOutSine" - | "easeInExpo" - | "easeOutExpo" - | "easeInOutExpo"; diff --git a/client-src/views/draw/state/utils.ts b/client-src/views/draw/state/utils.ts deleted file mode 100644 index 7e753eb..0000000 --- a/client-src/views/draw/state/utils.ts +++ /dev/null @@ -1,20 +0,0 @@ -function cross(x: number[], y: number[], z: number[]): number { - return (y[0] - x[0]) * (z[1] - x[1]) - (z[0] - x[0]) * (y[1] - x[1]); -} - -export function pointInPolygon(p: number[], points: number[][]): boolean { - let wn = 0; // winding number - - points.forEach((a, i) => { - const b = points[(i + 1) % points.length]; - if (a[1] <= p[1]) { - if (b[1] > p[1] && cross(a, b, p) > 0) { - wn += 1; - } - } else if (b[1] <= p[1] && cross(a, b, p) < 0) { - wn -= 1; - } - }); - - return wn !== 0; -}