@benev/tact 0.1.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +299 -0
  3. package/package.json +60 -0
  4. package/s/demo/main.bundle.ts +14 -0
  5. package/s/demo/main.css +57 -0
  6. package/s/index.html.ts +42 -0
  7. package/s/index.ts +16 -0
  8. package/s/nubs/lookpad/styles.ts +21 -0
  9. package/s/nubs/lookpad/utils/listeners.ts +53 -0
  10. package/s/nubs/lookpad/view.ts +32 -0
  11. package/s/nubs/stick/device.ts +30 -0
  12. package/s/nubs/stick/styles.ts +22 -0
  13. package/s/nubs/stick/utils/calculate_new_vector_from_pointer_position.ts +27 -0
  14. package/s/nubs/stick/utils/find_closest_point_on_circle.ts +15 -0
  15. package/s/nubs/stick/utils/make_pointer_listeners.ts +50 -0
  16. package/s/nubs/stick/utils/within_radius.ts +6 -0
  17. package/s/nubs/stick/view.ts +50 -0
  18. package/s/nubs/stick-graphic/styles.ts +38 -0
  19. package/s/nubs/stick-graphic/types/basis.ts +5 -0
  20. package/s/nubs/stick-graphic/utils/calculate_basis.ts +19 -0
  21. package/s/nubs/stick-graphic/utils/stick_vector_to_pixels.ts +13 -0
  22. package/s/nubs/stick-graphic/utils/transform.ts +10 -0
  23. package/s/nubs/stick-graphic/view.ts +43 -0
  24. package/s/nubs/virtual-gamepad/device.ts +25 -0
  25. package/s/nubs/virtual-gamepad/styles.css.ts +133 -0
  26. package/s/nubs/virtual-gamepad/utils/gamepad-inputs.ts +42 -0
  27. package/s/nubs/virtual-gamepad/utils/prevent-default-touch-shenanigans.ts +12 -0
  28. package/s/nubs/virtual-gamepad/utils/touch-tracking.ts +75 -0
  29. package/s/nubs/virtual-gamepad/view.ts +139 -0
  30. package/s/station/devices/gamepad.ts +81 -0
  31. package/s/station/devices/infra/device.ts +7 -0
  32. package/s/station/devices/infra/group.ts +17 -0
  33. package/s/station/devices/infra/sampler.ts +22 -0
  34. package/s/station/devices/keyboard.ts +53 -0
  35. package/s/station/devices/pointer.ts +95 -0
  36. package/s/station/parts/action.ts +26 -0
  37. package/s/station/parts/defaults.ts +28 -0
  38. package/s/station/parts/resolver.ts +73 -0
  39. package/s/station/parts/routines/aggregate_samples_into_map.ts +20 -0
  40. package/s/station/parts/routines/build_updatable_actions_structure.ts +29 -0
  41. package/s/station/parts/routines/lensing_algorithm.ts +74 -0
  42. package/s/station/parts/switchboard-bindings.ts +21 -0
  43. package/s/station/station.test.ts +86 -0
  44. package/s/station/station.ts +47 -0
  45. package/s/station/switchboard.ts +107 -0
  46. package/s/station/testing/testing.ts +47 -0
  47. package/s/station/types.ts +72 -0
  48. package/s/station/utils/is-pressed.ts +5 -0
  49. package/s/station/utils/modprefix.ts +16 -0
  50. package/s/station/utils/tmax.ts +7 -0
  51. package/s/station/utils/tmin.ts +7 -0
  52. package/s/tests.test.ts +8 -0
  53. package/s/utils/evergreen.ts +10 -0
  54. package/s/utils/gamepads.ts +41 -0
  55. package/s/utils/split-axis.ts +7 -0
  56. package/x/demo/main.bundle.d.ts +1 -0
  57. package/x/demo/main.bundle.js +11 -0
  58. package/x/demo/main.bundle.js.map +1 -0
  59. package/x/demo/main.bundle.min.js +139 -0
  60. package/x/demo/main.bundle.min.js.map +7 -0
  61. package/x/demo/main.css +57 -0
  62. package/x/index.d.ts +13 -0
  63. package/x/index.html +97 -0
  64. package/x/index.html.d.ts +2 -0
  65. package/x/index.html.js +37 -0
  66. package/x/index.html.js.map +1 -0
  67. package/x/index.js +14 -0
  68. package/x/index.js.map +1 -0
  69. package/x/nubs/lookpad/styles.d.ts +1 -0
  70. package/x/nubs/lookpad/styles.js +21 -0
  71. package/x/nubs/lookpad/styles.js.map +1 -0
  72. package/x/nubs/lookpad/utils/listeners.d.ts +19 -0
  73. package/x/nubs/lookpad/utils/listeners.js +37 -0
  74. package/x/nubs/lookpad/utils/listeners.js.map +1 -0
  75. package/x/nubs/lookpad/view.d.ts +1 -0
  76. package/x/nubs/lookpad/view.js +24 -0
  77. package/x/nubs/lookpad/view.js.map +1 -0
  78. package/x/nubs/stick/device.d.ts +15 -0
  79. package/x/nubs/stick/device.js +27 -0
  80. package/x/nubs/stick/device.js.map +1 -0
  81. package/x/nubs/stick/styles.d.ts +1 -0
  82. package/x/nubs/stick/styles.js +22 -0
  83. package/x/nubs/stick/styles.js.map +1 -0
  84. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.d.ts +3 -0
  85. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js +16 -0
  86. package/x/nubs/stick/utils/calculate_new_vector_from_pointer_position.js.map +1 -0
  87. package/x/nubs/stick/utils/find_closest_point_on_circle.d.ts +2 -0
  88. package/x/nubs/stick/utils/find_closest_point_on_circle.js +6 -0
  89. package/x/nubs/stick/utils/find_closest_point_on_circle.js.map +1 -0
  90. package/x/nubs/stick/utils/make_pointer_listeners.d.ts +16 -0
  91. package/x/nubs/stick/utils/make_pointer_listeners.js +34 -0
  92. package/x/nubs/stick/utils/make_pointer_listeners.js.map +1 -0
  93. package/x/nubs/stick/utils/within_radius.d.ts +2 -0
  94. package/x/nubs/stick/utils/within_radius.js +4 -0
  95. package/x/nubs/stick/utils/within_radius.js.map +1 -0
  96. package/x/nubs/stick/view.d.ts +2 -0
  97. package/x/nubs/stick/view.js +38 -0
  98. package/x/nubs/stick/view.js.map +1 -0
  99. package/x/nubs/stick-graphic/styles.d.ts +1 -0
  100. package/x/nubs/stick-graphic/styles.js +38 -0
  101. package/x/nubs/stick-graphic/styles.js.map +1 -0
  102. package/x/nubs/stick-graphic/types/basis.d.ts +4 -0
  103. package/x/nubs/stick-graphic/types/basis.js +2 -0
  104. package/x/nubs/stick-graphic/types/basis.js.map +1 -0
  105. package/x/nubs/stick-graphic/utils/calculate_basis.d.ts +2 -0
  106. package/x/nubs/stick-graphic/utils/calculate_basis.js +10 -0
  107. package/x/nubs/stick-graphic/utils/calculate_basis.js.map +1 -0
  108. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.d.ts +2 -0
  109. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js +7 -0
  110. package/x/nubs/stick-graphic/utils/stick_vector_to_pixels.js.map +1 -0
  111. package/x/nubs/stick-graphic/utils/transform.d.ts +2 -0
  112. package/x/nubs/stick-graphic/utils/transform.js +7 -0
  113. package/x/nubs/stick-graphic/utils/transform.js.map +1 -0
  114. package/x/nubs/stick-graphic/view.d.ts +3 -0
  115. package/x/nubs/stick-graphic/view.js +30 -0
  116. package/x/nubs/stick-graphic/view.js.map +1 -0
  117. package/x/nubs/virtual-gamepad/device.d.ts +7 -0
  118. package/x/nubs/virtual-gamepad/device.js +20 -0
  119. package/x/nubs/virtual-gamepad/device.js.map +1 -0
  120. package/x/nubs/virtual-gamepad/styles.css.d.ts +2 -0
  121. package/x/nubs/virtual-gamepad/styles.css.js +133 -0
  122. package/x/nubs/virtual-gamepad/styles.css.js.map +1 -0
  123. package/x/nubs/virtual-gamepad/utils/gamepad-inputs.d.ts +29 -0
  124. package/x/nubs/virtual-gamepad/utils/gamepad-inputs.js +31 -0
  125. package/x/nubs/virtual-gamepad/utils/gamepad-inputs.js.map +1 -0
  126. package/x/nubs/virtual-gamepad/utils/prevent-default-touch-shenanigans.d.ts +1 -0
  127. package/x/nubs/virtual-gamepad/utils/prevent-default-touch-shenanigans.js +9 -0
  128. package/x/nubs/virtual-gamepad/utils/prevent-default-touch-shenanigans.js.map +1 -0
  129. package/x/nubs/virtual-gamepad/utils/touch-tracking.d.ts +6 -0
  130. package/x/nubs/virtual-gamepad/utils/touch-tracking.js +55 -0
  131. package/x/nubs/virtual-gamepad/utils/touch-tracking.js.map +1 -0
  132. package/x/nubs/virtual-gamepad/view.d.ts +2 -0
  133. package/x/nubs/virtual-gamepad/view.js +120 -0
  134. package/x/nubs/virtual-gamepad/view.js.map +1 -0
  135. package/x/station/devices/gamepad.d.ts +10 -0
  136. package/x/station/devices/gamepad.js +70 -0
  137. package/x/station/devices/gamepad.js.map +1 -0
  138. package/x/station/devices/infra/device.d.ts +4 -0
  139. package/x/station/devices/infra/device.js +3 -0
  140. package/x/station/devices/infra/device.js.map +1 -0
  141. package/x/station/devices/infra/group.d.ts +7 -0
  142. package/x/station/devices/infra/group.js +13 -0
  143. package/x/station/devices/infra/group.js.map +1 -0
  144. package/x/station/devices/infra/sampler.d.ts +8 -0
  145. package/x/station/devices/infra/sampler.js +17 -0
  146. package/x/station/devices/infra/sampler.js.map +1 -0
  147. package/x/station/devices/keyboard.d.ts +9 -0
  148. package/x/station/devices/keyboard.js +42 -0
  149. package/x/station/devices/keyboard.js.map +1 -0
  150. package/x/station/devices/pointer.d.ts +11 -0
  151. package/x/station/devices/pointer.js +79 -0
  152. package/x/station/devices/pointer.js.map +1 -0
  153. package/x/station/parts/action.d.ts +12 -0
  154. package/x/station/parts/action.js +23 -0
  155. package/x/station/parts/action.js.map +1 -0
  156. package/x/station/parts/defaults.d.ts +5 -0
  157. package/x/station/parts/defaults.js +22 -0
  158. package/x/station/parts/defaults.js.map +1 -0
  159. package/x/station/parts/resolver.d.ts +10 -0
  160. package/x/station/parts/resolver.js +63 -0
  161. package/x/station/parts/resolver.js.map +1 -0
  162. package/x/station/parts/routines/aggregate_samples_into_map.d.ts +3 -0
  163. package/x/station/parts/routines/aggregate_samples_into_map.js +11 -0
  164. package/x/station/parts/routines/aggregate_samples_into_map.js.map +1 -0
  165. package/x/station/parts/routines/build_updatable_actions_structure.d.ts +5 -0
  166. package/x/station/parts/routines/build_updatable_actions_structure.js +18 -0
  167. package/x/station/parts/routines/build_updatable_actions_structure.js.map +1 -0
  168. package/x/station/parts/routines/lensing_algorithm.d.ts +2 -0
  169. package/x/station/parts/routines/lensing_algorithm.js +42 -0
  170. package/x/station/parts/routines/lensing_algorithm.js.map +1 -0
  171. package/x/station/parts/switchboard-bindings.d.ts +2 -0
  172. package/x/station/parts/switchboard-bindings.js +19 -0
  173. package/x/station/parts/switchboard-bindings.js.map +1 -0
  174. package/x/station/station.d.ts +15 -0
  175. package/x/station/station.js +35 -0
  176. package/x/station/station.js.map +1 -0
  177. package/x/station/station.test.d.ts +11 -0
  178. package/x/station/station.test.js +80 -0
  179. package/x/station/station.test.js.map +1 -0
  180. package/x/station/switchboard.d.ts +30 -0
  181. package/x/station/switchboard.js +90 -0
  182. package/x/station/switchboard.js.map +1 -0
  183. package/x/station/testing/testing.d.ts +58 -0
  184. package/x/station/testing/testing.js +39 -0
  185. package/x/station/testing/testing.js.map +1 -0
  186. package/x/station/types.d.ts +56 -0
  187. package/x/station/types.js +5 -0
  188. package/x/station/types.js.map +1 -0
  189. package/x/station/utils/is-pressed.d.ts +1 -0
  190. package/x/station/utils/is-pressed.js +4 -0
  191. package/x/station/utils/is-pressed.js.map +1 -0
  192. package/x/station/utils/modprefix.d.ts +1 -0
  193. package/x/station/utils/modprefix.js +16 -0
  194. package/x/station/utils/modprefix.js.map +1 -0
  195. package/x/station/utils/tmax.d.ts +1 -0
  196. package/x/station/utils/tmax.js +6 -0
  197. package/x/station/utils/tmax.js.map +1 -0
  198. package/x/station/utils/tmin.d.ts +1 -0
  199. package/x/station/utils/tmin.js +6 -0
  200. package/x/station/utils/tmin.js.map +1 -0
  201. package/x/tests.test.d.ts +1 -0
  202. package/x/tests.test.js +6 -0
  203. package/x/tests.test.js.map +1 -0
  204. package/x/utils/evergreen.d.ts +1 -0
  205. package/x/utils/evergreen.js +10 -0
  206. package/x/utils/evergreen.js.map +1 -0
  207. package/x/utils/gamepads.d.ts +14 -0
  208. package/x/utils/gamepads.js +40 -0
  209. package/x/utils/gamepads.js.map +1 -0
  210. package/x/utils/split-axis.d.ts +1 -0
  211. package/x/utils/split-axis.js +6 -0
  212. package/x/utils/split-axis.js.map +1 -0
@@ -0,0 +1,57 @@
1
+
2
+ @layer vars, core, basics, page;
3
+
4
+ @layer vars {
5
+ :root {
6
+ color-scheme: dark;
7
+ --link: cyan;
8
+ --bg: #181818;
9
+ --prime: #aaa;
10
+ }
11
+ }
12
+
13
+ @layer core {
14
+ * {
15
+ padding: 0;
16
+ margin: 0;
17
+ box-sizing: border-box;
18
+ }
19
+
20
+ ::-webkit-scrollbar { width: 4px; }
21
+ ::-webkit-scrollbar-track { background: transparent; }
22
+ ::-webkit-scrollbar-thumb { background: #333; border-radius: 1em; }
23
+ ::-webkit-scrollbar-thumb:hover { background: #444; }
24
+
25
+ a {
26
+ color: var(--link);
27
+ text-decoration: none;
28
+
29
+ &:visited {
30
+ color: color-mix(in srgb, var(--link), purple 30%);
31
+ }
32
+
33
+ &:hover {
34
+ color: color-mix(in srgb, var(--link), white 10%);
35
+ text-decoration: underline;
36
+ }
37
+
38
+ &:active {
39
+ color: color-mix(in srgb, var(--link), white 50%);
40
+ }
41
+ }
42
+ }
43
+
44
+ @layer basics {
45
+ html { height: 100%; }
46
+ body { min-height: 100%; }
47
+
48
+ html, body {
49
+ font-size: 21px;
50
+ color: var(--prime);
51
+ background: var(--bg);
52
+ }
53
+ }
54
+
55
+ @layer page {
56
+ }
57
+
package/x/index.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ export * from "./station/devices/infra/device.js";
2
+ export * from "./station/devices/infra/group.js";
3
+ export * from "./station/devices/infra/sampler.js";
4
+ export * from "./station/devices/gamepad.js";
5
+ export * from "./station/devices/keyboard.js";
6
+ export * from "./station/devices/pointer.js";
7
+ export * from "./station/parts/action.js";
8
+ export * from "./station/utils/modprefix.js";
9
+ export * from "./station/station.js";
10
+ export * from "./station/switchboard.js";
11
+ export * from "./station/types.js";
12
+ export * from "./utils/gamepads.js";
13
+ export * from "./utils/split-axis.js";
package/x/index.html ADDED
@@ -0,0 +1,97 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1"/>
6
+ <meta name="darkreader-lock"/>
7
+ <title>@benev/tact</title>
8
+ <style>
9
+ @layer vars, core, basics, page;
10
+
11
+ @layer vars {
12
+ :root {
13
+ color-scheme: dark;
14
+ --link: cyan;
15
+ --bg: #181818;
16
+ --prime: #aaa;
17
+ }
18
+ }
19
+
20
+ @layer core {
21
+ * {
22
+ padding: 0;
23
+ margin: 0;
24
+ box-sizing: border-box;
25
+ }
26
+
27
+ ::-webkit-scrollbar { width: 4px; }
28
+ ::-webkit-scrollbar-track { background: transparent; }
29
+ ::-webkit-scrollbar-thumb { background: #333; border-radius: 1em; }
30
+ ::-webkit-scrollbar-thumb:hover { background: #444; }
31
+
32
+ a {
33
+ color: var(--link);
34
+ text-decoration: none;
35
+
36
+ &:visited {
37
+ color: color-mix(in srgb, var(--link), purple 30%);
38
+ }
39
+
40
+ &:hover {
41
+ color: color-mix(in srgb, var(--link), white 10%);
42
+ text-decoration: underline;
43
+ }
44
+
45
+ &:active {
46
+ color: color-mix(in srgb, var(--link), white 50%);
47
+ }
48
+ }
49
+ }
50
+
51
+ @layer basics {
52
+ html { height: 100%; }
53
+ body { min-height: 100%; }
54
+
55
+ html, body {
56
+ font-size: 21px;
57
+ color: var(--prime);
58
+ background: var(--bg);
59
+ }
60
+ }
61
+
62
+ @layer page {
63
+ }
64
+
65
+ </style>
66
+ <script type=module src="demo/main.bundle.min.js?v=51b813571898"></script>
67
+ <link rel="icon" href="assets/b.png?v=32b1d0126431"/>
68
+
69
+ <meta name="theme-color" content="#f2ea8e">
70
+ <meta property="og:type" content="website">
71
+ <meta property="og:site_name" content="tact.benevolent.games">
72
+ <meta property="og:title" content="@benev/tact">
73
+ <meta property="og:description" content="keybindings and gamepad support for web games">
74
+ <meta property="og:image" content="https://tact.benevolent.games/assets/b.png">
75
+
76
+
77
+
78
+ <meta data-version="0.1.0-1" />
79
+
80
+ </head>
81
+ <body>
82
+
83
+ <header>
84
+ <h1>
85
+ <strong>@benev/tact</strong>
86
+ <span>v0.1.0-1</span>
87
+ </h1>
88
+ <div class=deets>
89
+ <a href="https://github.com/benevolent-games/tact">github</a>
90
+ <a href="https://benevolent.games/">benevolent.games</a>
91
+ </div>
92
+ </header>
93
+
94
+ <tact-demo></tact-demo>
95
+
96
+ </body>
97
+ </html>
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@e280/scute").TemplateFn;
2
+ export default _default;
@@ -0,0 +1,37 @@
1
+ import { ssg, html } from "@e280/scute";
2
+ const title = "@benev/tact";
3
+ const domain = "tact.benevolent.games";
4
+ const favicon = "/assets/b.png";
5
+ const description = "keybindings and gamepad support for web games";
6
+ export default ssg.page(import.meta.url, async (orb) => ({
7
+ title,
8
+ js: "demo/main.bundle.min.js",
9
+ css: "demo/main.css",
10
+ dark: true,
11
+ favicon,
12
+ head: html `
13
+ <meta data-version="${orb.packageVersion()}" />
14
+ `,
15
+ socialCard: {
16
+ title,
17
+ description,
18
+ themeColor: "#f2ea8e",
19
+ siteName: domain,
20
+ image: `https://${domain}${favicon}`,
21
+ },
22
+ body: html `
23
+ <header>
24
+ <h1>
25
+ <strong>@benev/tact</strong>
26
+ <span>v${orb.packageVersion()}</span>
27
+ </h1>
28
+ <div class=deets>
29
+ <a href="https://github.com/benevolent-games/tact">github</a>
30
+ <a href="https://benevolent.games/">benevolent.games</a>
31
+ </div>
32
+ </header>
33
+
34
+ <tact-demo></tact-demo>
35
+ `,
36
+ }));
37
+ //# sourceMappingURL=index.html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.html.js","sourceRoot":"","sources":["../s/index.html.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,aAAa,CAAA;AAErC,MAAM,KAAK,GAAG,aAAa,CAAA;AAC3B,MAAM,MAAM,GAAG,uBAAuB,CAAA;AACtC,MAAM,OAAO,GAAG,eAAe,CAAA;AAC/B,MAAM,WAAW,GAAG,+CAA+C,CAAA;AAEnE,eAAe,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAC,GAAG,EAAC,EAAE,CAAC,CAAC;IACtD,KAAK;IACL,EAAE,EAAE,yBAAyB;IAC7B,GAAG,EAAE,eAAe;IACpB,IAAI,EAAE,IAAI;IACV,OAAO;IACP,IAAI,EAAE,IAAI,CAAA;wBACa,GAAG,CAAC,cAAc,EAAE;EAC1C;IAED,UAAU,EAAE;QACX,KAAK;QACL,WAAW;QACX,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE,WAAW,MAAM,GAAG,OAAO,EAAE;KACpC;IAED,IAAI,EAAE,IAAI,CAAA;;;;aAIE,GAAG,CAAC,cAAc,EAAE;;;;;;;;;EAS/B;CACD,CAAC,CAAC,CAAA"}
package/x/index.js ADDED
@@ -0,0 +1,14 @@
1
+ export * from "./station/devices/infra/device.js";
2
+ export * from "./station/devices/infra/group.js";
3
+ export * from "./station/devices/infra/sampler.js";
4
+ export * from "./station/devices/gamepad.js";
5
+ export * from "./station/devices/keyboard.js";
6
+ export * from "./station/devices/pointer.js";
7
+ export * from "./station/parts/action.js";
8
+ export * from "./station/utils/modprefix.js";
9
+ export * from "./station/station.js";
10
+ export * from "./station/switchboard.js";
11
+ export * from "./station/types.js";
12
+ export * from "./utils/gamepads.js";
13
+ export * from "./utils/split-axis.js";
14
+ //# sourceMappingURL=index.js.map
package/x/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../s/index.ts"],"names":[],"mappings":"AACA,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,oCAAoC,CAAA;AAClD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAElC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,21 @@
1
+ import { css } from "lit";
2
+ export const styles = css `
3
+
4
+ :host {
5
+ display: block;
6
+ width: 10em;
7
+ height: 10em;
8
+
9
+ user-select: none;
10
+ border: 1px solid;
11
+
12
+ touch-action: none;
13
+ }
14
+
15
+ .pad {
16
+ width: 100%;
17
+ height: 100%;
18
+ }
19
+
20
+ `;
21
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../s/nubs/lookpad/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAA;AACvB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;CAkBxB,CAAA"}
@@ -0,0 +1,19 @@
1
+ export declare function lookpad_listeners({ onPointerDrag, getPointerCaptureElement, }: {
2
+ onPointerDrag: (event: PointerEvent) => void;
3
+ getPointerCaptureElement: () => HTMLElement;
4
+ }): {
5
+ pointerdown: {
6
+ options: undefined;
7
+ handleEvent: (event: PointerEvent) => void;
8
+ };
9
+ pointermove: {
10
+ options: {
11
+ passive: boolean;
12
+ };
13
+ handleEvent: (event: PointerEvent) => void;
14
+ };
15
+ pointerup: {
16
+ options: undefined;
17
+ handleEvent: (event: PointerEvent) => void;
18
+ };
19
+ };
@@ -0,0 +1,37 @@
1
+ export function lookpad_listeners({ onPointerDrag, getPointerCaptureElement, }) {
2
+ let pointer_id;
3
+ return {
4
+ pointerdown: {
5
+ options: undefined,
6
+ handleEvent: (event) => {
7
+ event.preventDefault();
8
+ const element = getPointerCaptureElement();
9
+ if (pointer_id)
10
+ element.releasePointerCapture(pointer_id);
11
+ pointer_id = event.pointerId;
12
+ element.setPointerCapture(pointer_id);
13
+ onPointerDrag(event);
14
+ },
15
+ },
16
+ pointermove: {
17
+ options: { passive: false },
18
+ handleEvent: (event) => {
19
+ event.preventDefault();
20
+ if (event.pointerId === pointer_id)
21
+ onPointerDrag(event);
22
+ },
23
+ },
24
+ pointerup: {
25
+ options: undefined,
26
+ handleEvent: (event) => {
27
+ event.preventDefault();
28
+ if (event.pointerId === pointer_id) {
29
+ getPointerCaptureElement().releasePointerCapture(pointer_id);
30
+ pointer_id = undefined;
31
+ onPointerDrag(event);
32
+ }
33
+ },
34
+ },
35
+ };
36
+ }
37
+ //# sourceMappingURL=listeners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listeners.js","sourceRoot":"","sources":["../../../../s/nubs/lookpad/utils/listeners.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,iBAAiB,CAAC,EAChC,aAAa,EACb,wBAAwB,GAIxB;IAED,IAAI,UAA8B,CAAA;IAElC,OAAO;QACN,WAAW,EAAE;YACZ,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,CAAC,KAAmB,EAAE,EAAE;gBACpC,KAAK,CAAC,cAAc,EAAE,CAAA;gBAEtB,MAAM,OAAO,GAAG,wBAAwB,EAAE,CAAA;gBAE1C,IAAI,UAAU;oBACb,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;gBAE1C,UAAU,GAAG,KAAK,CAAC,SAAS,CAAA;gBAC5B,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;gBACrC,aAAa,CAAC,KAAK,CAAC,CAAA;YACrB,CAAC;SACD;QAED,WAAW,EAAE;YACZ,OAAO,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC;YACzB,WAAW,EAAE,CAAC,KAAmB,EAAE,EAAE;gBACpC,KAAK,CAAC,cAAc,EAAE,CAAA;gBAEtB,IAAI,KAAK,CAAC,SAAS,KAAK,UAAU;oBACjC,aAAa,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;SACD;QAED,SAAS,EAAE;YACV,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,CAAC,KAAmB,EAAE,EAAE;gBACpC,KAAK,CAAC,cAAc,EAAE,CAAA;gBAEtB,IAAI,KAAK,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;oBACpC,wBAAwB,EAAE,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;oBAC5D,UAAU,GAAG,SAAS,CAAA;oBACtB,aAAa,CAAC,KAAK,CAAC,CAAA;gBACrB,CAAC;YACF,CAAC;SACD;KACD,CAAA;AACF,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const NubLookpad: import("@e280/sly").View<[]>;
@@ -0,0 +1,24 @@
1
+ import { html } from "lit";
2
+ import { view } from "@e280/sly";
3
+ import { styles } from "./styles.js";
4
+ import { lookpad_listeners } from "./utils/listeners.js";
5
+ export const NubLookpad = view(use => () => {
6
+ use.name("nub-lookpad");
7
+ use.styles(styles);
8
+ const pad = use.life(() => {
9
+ const pad = document.createElement("div");
10
+ pad.className = "pad";
11
+ const listeners = lookpad_listeners({
12
+ getPointerCaptureElement: () => pad,
13
+ onPointerDrag: () => { },
14
+ });
15
+ for (const [event, { handleEvent, options }] of Object.entries(listeners))
16
+ pad.addEventListener(event, handleEvent, options);
17
+ return [pad, () => {
18
+ for (const [event, { handleEvent }] of Object.entries(listeners))
19
+ pad.removeEventListener(event, handleEvent);
20
+ }];
21
+ });
22
+ return html `${pad}`;
23
+ });
24
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../s/nubs/lookpad/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAE9B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAA;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE;IAC1C,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IACvB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAElB,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE;QACzB,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QACzC,GAAG,CAAC,SAAS,GAAG,KAAK,CAAA;QAErB,MAAM,SAAS,GAAG,iBAAiB,CAAC;YACnC,wBAAwB,EAAE,GAAG,EAAE,CAAC,GAAG;YACnC,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;SACvB,CAAC,CAAA;QAEF,KAAK,MAAM,CAAC,KAAK,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;YACtE,GAAG,CAAC,gBAAgB,CAAC,KAAY,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;QAEzD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE;gBACjB,KAAK,MAAM,CAAC,KAAK,EAAE,EAAC,WAAW,EAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;oBAC7D,GAAG,CAAC,mBAAmB,CAAC,KAAY,EAAE,WAAW,CAAC,CAAA;YACpD,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA,GAAG,GAAG,EAAE,CAAA;AACpB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { Vec2 } from "@benev/math";
2
+ import { Disposable } from "@e280/stz";
3
+ import { SamplerDevice } from "../../station/devices/infra/sampler.js";
4
+ export declare class StickDevice extends SamplerDevice implements Disposable {
5
+ channel: string;
6
+ vector: import("@e280/strata").Signal<Vec2>;
7
+ dispose: () => void;
8
+ constructor(channel?: string);
9
+ breakdown(): {
10
+ up: number;
11
+ down: number;
12
+ left: number;
13
+ right: number;
14
+ };
15
+ }
@@ -0,0 +1,27 @@
1
+ import { Vec2 } from "@benev/math";
2
+ import { signal } from "@e280/strata";
3
+ import { splitAxis } from "../../utils/split-axis.js";
4
+ import { SamplerDevice } from "../../station/devices/infra/sampler.js";
5
+ export class StickDevice extends SamplerDevice {
6
+ channel;
7
+ vector = signal(Vec2.zero());
8
+ dispose;
9
+ constructor(channel = "stick") {
10
+ super();
11
+ this.channel = channel;
12
+ this.dispose = this.vector.on(() => {
13
+ const { up, down, left, right } = this.breakdown();
14
+ this.setSample(`${channel}.up`, up);
15
+ this.setSample(`${channel}.down`, down);
16
+ this.setSample(`${channel}.left`, left);
17
+ this.setSample(`${channel}.right`, right);
18
+ });
19
+ }
20
+ breakdown() {
21
+ const { x, y } = this.vector.get();
22
+ const [down, up] = splitAxis(y);
23
+ const [left, right] = splitAxis(x);
24
+ return { up, down, left, right };
25
+ }
26
+ }
27
+ //# sourceMappingURL=device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"device.js","sourceRoot":"","sources":["../../../s/nubs/stick/device.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAC,SAAS,EAAC,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,wCAAwC,CAAA;AAEpE,MAAM,OAAO,WAAY,SAAQ,aAAa;IAI1B;IAHnB,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IAC5B,OAAO,CAAY;IAEnB,YAAmB,UAAU,OAAO;QACnC,KAAK,EAAE,CAAA;QADW,YAAO,GAAP,OAAO,CAAU;QAEnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE;YAClC,MAAM,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;YAChD,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO,KAAK,EAAE,EAAE,CAAC,CAAA;YACnC,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO,OAAO,EAAE,IAAI,CAAC,CAAA;YACvC,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO,OAAO,EAAE,IAAI,CAAC,CAAA;YACvC,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO,QAAQ,EAAE,KAAK,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;IACH,CAAC;IAED,SAAS;QACR,MAAM,EAAC,CAAC,EAAE,CAAC,EAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;QAChC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;QAClC,OAAO,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAC,CAAA;IAC/B,CAAC;CACD"}
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,22 @@
1
+ import { css } from "lit";
2
+ export const styles = css `
3
+
4
+ :host {
5
+ display: block;
6
+ width: 8em;
7
+ aspect-ratio: 1 / 1;
8
+ touch-action: none;
9
+ }
10
+
11
+ .container {
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+
16
+ [part="graphic"] {
17
+ width: 100%;
18
+ height: 100%;
19
+ }
20
+
21
+ `;
22
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../s/nubs/stick/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAA;AACvB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;CAmBxB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Vec2 } from "@benev/math";
2
+ import { Basis } from "../../stick-graphic/types/basis.js";
3
+ export declare function calculate_new_vector_from_pointer_position({ radius, rect: { left, top, width, height } }: Basis, { x: client_x, y: client_y }: Vec2): Vec2;
@@ -0,0 +1,16 @@
1
+ import { Vec2 } from "@benev/math";
2
+ import { within_radius } from "./within_radius.js";
3
+ import { find_closest_point_on_circle } from "./find_closest_point_on_circle.js";
4
+ export function calculate_new_vector_from_pointer_position({ radius, rect: { left, top, width, height } }, { x: client_x, y: client_y }) {
5
+ const middle_x = left + (width / 2);
6
+ const middle_y = top + (height / 2);
7
+ let new_vector = Vec2.new((client_x - middle_x), (client_y - middle_y));
8
+ if (!within_radius(radius, new_vector))
9
+ new_vector = find_closest_point_on_circle(radius, new_vector);
10
+ const [x, y] = new_vector;
11
+ const final = Vec2.new((x / radius), -(y / radius));
12
+ return [...final].some(isNaN)
13
+ ? Vec2.zero()
14
+ : final;
15
+ }
16
+ //# sourceMappingURL=calculate_new_vector_from_pointer_position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate_new_vector_from_pointer_position.js","sourceRoot":"","sources":["../../../../s/nubs/stick/utils/calculate_new_vector_from_pointer_position.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAChC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAA;AAE9E,MAAM,UAAU,0CAA0C,CACxD,EAAC,MAAM,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAC,EAAQ,EACjD,EAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAO;IAGjC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;IACnC,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAEnC,IAAI,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAA;IAEvE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC;QACrC,UAAU,GAAG,4BAA4B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9D,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAA;IAEzB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAA;IAEnD,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5B,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE;QACb,CAAC,CAAC,KAAK,CAAA;AACT,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Vec2 } from "@benev/math";
2
+ export declare function find_closest_point_on_circle(radius: number, { x, y }: Vec2): Vec2;
@@ -0,0 +1,6 @@
1
+ import { Vec2 } from "@benev/math";
2
+ export function find_closest_point_on_circle(radius, { x, y }) {
3
+ const magnitude = Math.sqrt((x ** 2) + (y ** 2));
4
+ return Vec2.new((x / magnitude) * radius, (y / magnitude) * radius);
5
+ }
6
+ //# sourceMappingURL=find_closest_point_on_circle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find_closest_point_on_circle.js","sourceRoot":"","sources":["../../../../s/nubs/stick/utils/find_closest_point_on_circle.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,MAAM,UAAU,4BAA4B,CAC1C,MAAc,EACd,EAAC,CAAC,EAAE,CAAC,EAAO;IAGb,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAEhD,OAAO,IAAI,CAAC,GAAG,CACd,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,MAAM,EACxB,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,MAAM,CACxB,CAAA;AACF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Vec2 } from "@benev/math";
2
+ export declare function make_pointer_listeners({ set_vector, set_pointer_position, }: {
3
+ set_vector: (vector: Vec2) => void;
4
+ set_pointer_position: (position: Vec2) => void;
5
+ }): {
6
+ pointerdown: {
7
+ handleEvent: (event: PointerEvent) => void;
8
+ };
9
+ pointermove: {
10
+ passive: boolean;
11
+ handleEvent: (event: PointerEvent) => void;
12
+ };
13
+ pointerup: {
14
+ handleEvent: (event: PointerEvent) => void;
15
+ };
16
+ };
@@ -0,0 +1,34 @@
1
+ import { Vec2 } from "@benev/math";
2
+ export function make_pointer_listeners({ set_vector, set_pointer_position, }) {
3
+ let pointer_id;
4
+ return {
5
+ pointerdown: {
6
+ handleEvent: (event) => {
7
+ event.preventDefault();
8
+ const element = event.currentTarget;
9
+ if (pointer_id)
10
+ element.releasePointerCapture(pointer_id);
11
+ pointer_id = event.pointerId;
12
+ element.setPointerCapture(pointer_id);
13
+ set_pointer_position(Vec2.new(event.clientX, event.clientY));
14
+ set_vector(Vec2.zero());
15
+ },
16
+ },
17
+ pointermove: {
18
+ passive: false,
19
+ handleEvent: (event) => {
20
+ event.preventDefault();
21
+ if (event.pointerId === pointer_id)
22
+ set_pointer_position(Vec2.new(event.clientX, event.clientY));
23
+ },
24
+ },
25
+ pointerup: {
26
+ handleEvent: (event) => {
27
+ event.preventDefault();
28
+ pointer_id = undefined;
29
+ set_vector(Vec2.zero());
30
+ },
31
+ },
32
+ };
33
+ }
34
+ //# sourceMappingURL=make_pointer_listeners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make_pointer_listeners.js","sourceRoot":"","sources":["../../../../s/nubs/stick/utils/make_pointer_listeners.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,MAAM,UAAU,sBAAsB,CAAC,EACrC,UAAU,EACV,oBAAoB,GAIpB;IAED,IAAI,UAA8B,CAAA;IAElC,OAAO;QACN,WAAW,EAAE;YACZ,WAAW,EAAE,CAAC,KAAmB,EAAE,EAAE;gBACpC,KAAK,CAAC,cAAc,EAAE,CAAA;gBAEtB,MAAM,OAAO,GAAG,KAAK,CAAC,aAA4B,CAAA;gBAElD,IAAI,UAAU;oBACb,OAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAA;gBAE1C,UAAU,GAAG,KAAK,CAAC,SAAS,CAAA;gBAC5B,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;gBACrC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;gBAC5D,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;YACxB,CAAC;SACD;QAED,WAAW,EAAE;YACZ,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,CAAC,KAAmB,EAAE,EAAE;gBACpC,KAAK,CAAC,cAAc,EAAE,CAAA;gBAEtB,IAAI,KAAK,CAAC,SAAS,KAAK,UAAU;oBACjC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;YAC9D,CAAC;SACD;QAED,SAAS,EAAE;YACV,WAAW,EAAE,CAAC,KAAmB,EAAE,EAAE;gBACpC,KAAK,CAAC,cAAc,EAAE,CAAA;gBACtB,UAAU,GAAG,SAAS,CAAA;gBACtB,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;YACxB,CAAC;SACD;KACD,CAAA;AACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Vec2 } from "@benev/math";
2
+ export declare function within_radius(radius: number, { x, y }: Vec2): boolean;
@@ -0,0 +1,4 @@
1
+ export function within_radius(radius, { x, y }) {
2
+ return (x ** 2) + (y ** 2) < (radius ** 2);
3
+ }
4
+ //# sourceMappingURL=within_radius.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"within_radius.js","sourceRoot":"","sources":["../../../../s/nubs/stick/utils/within_radius.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,EAAC,CAAC,EAAE,CAAC,EAAO;IACzD,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAA;AAC3C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { StickDevice } from "./device.js";
2
+ export declare const NubStick: import("@e280/sly").View<[stick: StickDevice]>;
@@ -0,0 +1,38 @@
1
+ import { html } from "lit";
2
+ import { view } from "@e280/sly";
3
+ import { Vec2 } from "@benev/math";
4
+ import { styles } from "./styles.js";
5
+ import { NubStickGraphic } from "../stick-graphic/view.js";
6
+ import { make_pointer_listeners } from "./utils/make_pointer_listeners.js";
7
+ import { calculate_new_vector_from_pointer_position } from "./utils/calculate_new_vector_from_pointer_position.js";
8
+ export const NubStick = view(use => (stick) => {
9
+ use.name("nub-stick");
10
+ use.styles(styles);
11
+ let basis = undefined;
12
+ const updateBasis = (b) => basis = b;
13
+ const listeners = use.once(() => make_pointer_listeners({
14
+ set_vector: vector => stick.vector.value = vector,
15
+ set_pointer_position: position => {
16
+ if (basis)
17
+ stick.vector.value = calculate_new_vector_from_pointer_position(basis, position);
18
+ },
19
+ }));
20
+ use.mount(() => {
21
+ stick.vector.set(Vec2.zero());
22
+ return () => stick.vector.set(Vec2.zero());
23
+ });
24
+ return html `
25
+ <div
26
+ class=container
27
+ .vector="${stick.vector}"
28
+ @pointerdown="${listeners.pointerdown}"
29
+ @pointermove="${listeners.pointermove}"
30
+ @pointerup="${listeners.pointerup}"
31
+ >
32
+ ${NubStickGraphic
33
+ .attr("part", "graphic")
34
+ .props(stick.vector.get(), updateBasis)}
35
+ </div>
36
+ `;
37
+ });
38
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../s/nubs/stick/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAGhC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAC,sBAAsB,EAAC,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAC,0CAA0C,EAAC,MAAM,uDAAuD,CAAA;AAEhH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAkB,EAAE,EAAE;IAC1D,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACrB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAElB,IAAI,KAAK,GAAsB,SAAS,CAAA;IACxC,MAAM,WAAW,GAAG,CAAC,CAAQ,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAA;IAE3C,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;QACvD,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM;QACjD,oBAAoB,EAAE,QAAQ,CAAC,EAAE;YAChC,IAAI,KAAK;gBACR,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,0CAA0C,CAC9D,KAAK,EACL,QAAQ,CACR,CAAA;QACH,CAAC;KACD,CAAC,CAAC,CAAA;IAEH,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE;QACd,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7B,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;;;cAGE,KAAK,CAAC,MAAM;mBACP,SAAS,CAAC,WAAW;mBACrB,SAAS,CAAC,WAAW;iBACvB,SAAS,CAAC,SAAS;;KAE/B,eAAe;SACf,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;SACvB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC;;EAEzC,CAAA;AACF,CAAC,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,38 @@
1
+ import { css } from "lit";
2
+ export const styles = css `
3
+
4
+ :host {
5
+ display: block;
6
+ width: 8em;
7
+ height: 8em;
8
+ --size: var(--nub-stick-size, 66%);
9
+ --background: var(--nub-stick-background, black);
10
+ --color: var(--nub-stick-color, white);
11
+ }
12
+
13
+ [part="base"] {
14
+ position: relative;
15
+ aspect-ratio: 1/1;
16
+ width: 100%;
17
+ height: 100%;
18
+ background: var(--background);
19
+ border-radius: 100%;
20
+ }
21
+
22
+ [part="over"], [part="under"] {
23
+ position: absolute;
24
+ inset: 0;
25
+ width: var(--size);
26
+ height: var(--size);
27
+ border-radius: 100%;
28
+ margin: auto;
29
+ pointer-events: none;
30
+ background: var(--color);
31
+ }
32
+
33
+ [part="under"] {
34
+ opacity: 0.5;
35
+ }
36
+
37
+ `;
38
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../s/nubs/stick-graphic/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAA;AACvB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCxB,CAAA"}