effect-motion 0.2.0 → 0.3.0

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 (103) hide show
  1. package/dist/Camera.d.ts +50 -28
  2. package/dist/Camera.js +71 -19
  3. package/dist/CameraHelpers.d.ts +70 -0
  4. package/dist/CameraHelpers.js +239 -0
  5. package/dist/CanvasExporter.d.ts +12 -0
  6. package/dist/CanvasExporter.js +40 -0
  7. package/dist/Color.d.ts +428 -0
  8. package/dist/Color.js +535 -0
  9. package/dist/EffectMotionError.d.ts +10 -0
  10. package/dist/EffectMotionError.js +6 -0
  11. package/dist/Entity.d.ts +9 -8
  12. package/dist/Entity.js +1 -4
  13. package/dist/Fonts.d.ts +10 -0
  14. package/dist/Fonts.js +16 -0
  15. package/dist/Images.d.ts +33 -0
  16. package/dist/Images.js +24 -0
  17. package/dist/Instance.d.ts +4 -4
  18. package/dist/Motion.d.ts +24 -7
  19. package/dist/Motion.js +54 -9
  20. package/dist/Phaser.d.ts +1 -1
  21. package/dist/Phaser.js +13 -9
  22. package/dist/Physics.d.ts +3 -3
  23. package/dist/Physics.js +4 -4
  24. package/dist/PngExporter.d.ts +6 -0
  25. package/dist/PngExporter.js +85 -0
  26. package/dist/Projection.d.ts +225 -0
  27. package/dist/Projection.js +473 -0
  28. package/dist/Renderer.d.ts +102 -53
  29. package/dist/Renderer.js +369 -78
  30. package/dist/Runner.d.ts +126 -42
  31. package/dist/Runner.js +42 -17
  32. package/dist/Scene.d.ts +88 -59
  33. package/dist/Scene.js +24 -15
  34. package/dist/Shapes.d.ts +11 -0
  35. package/dist/Shapes.js +11 -0
  36. package/dist/demo.d.ts +3 -186
  37. package/dist/demo.js +24 -35
  38. package/dist/index.d.ts +14 -13
  39. package/dist/index.js +14 -13
  40. package/dist/particles/Particle.d.ts +4 -3
  41. package/dist/particles/ParticleField.d.ts +11 -48
  42. package/dist/particles/ParticleField.js +5 -4
  43. package/dist/particles/constructors.d.ts +8 -7
  44. package/dist/particles/constructors.js +2 -2
  45. package/dist/particles/index.d.ts +5 -6
  46. package/dist/particles/index.js +5 -6
  47. package/dist/particles/overLife.d.ts +1 -1
  48. package/dist/particles/overLife.js +1 -1
  49. package/dist/particles/simulate.d.ts +2 -2
  50. package/dist/particles/simulate.js +6 -6
  51. package/dist/particles/step.d.ts +2 -2
  52. package/dist/particles/step.js +5 -3
  53. package/dist/render/dof.d.ts +27 -0
  54. package/dist/render/dof.js +37 -0
  55. package/dist/render/paint.d.ts +30 -0
  56. package/dist/render/paint.js +36 -0
  57. package/dist/render/shapes.d.ts +42 -0
  58. package/dist/render/shapes.js +310 -0
  59. package/dist/shapes/Circle.d.ts +10 -15
  60. package/dist/shapes/Circle.js +2 -2
  61. package/dist/shapes/Ellipse.d.ts +10 -16
  62. package/dist/shapes/Ellipse.js +2 -2
  63. package/dist/shapes/Group.d.ts +5 -39
  64. package/dist/shapes/Group.js +4 -4
  65. package/dist/shapes/Hud.d.ts +38 -0
  66. package/dist/shapes/Hud.js +35 -0
  67. package/dist/shapes/Image.d.ts +45 -0
  68. package/dist/shapes/Image.js +28 -0
  69. package/dist/shapes/Line.d.ts +12 -12
  70. package/dist/shapes/Line.js +11 -6
  71. package/dist/shapes/Path.d.ts +87 -18
  72. package/dist/shapes/Path.js +25 -6
  73. package/dist/shapes/Rect.d.ts +33 -23
  74. package/dist/shapes/Rect.js +14 -2
  75. package/dist/shapes/Shape2D.d.ts +13 -4
  76. package/dist/shapes/Shape2D.js +16 -5
  77. package/dist/shapes/Shapes.d.ts +11 -0
  78. package/dist/shapes/Shapes.js +11 -0
  79. package/dist/shapes/Square.d.ts +10 -15
  80. package/dist/shapes/Square.js +2 -2
  81. package/dist/shapes/Text.d.ts +10 -19
  82. package/dist/shapes/Text.js +2 -2
  83. package/package.json +14 -4
  84. package/dist/particles/render.d.ts +0 -13
  85. package/dist/particles/render.js +0 -33
  86. package/dist/shapes/Layer.d.ts +0 -9
  87. package/dist/shapes/Layer.js +0 -23
  88. package/dist/shapes/index.d.ts +0 -10
  89. package/dist/shapes/index.js +0 -10
  90. package/dist/svg/SvgDomRenderer.d.ts +0 -28
  91. package/dist/svg/SvgDomRenderer.js +0 -50
  92. package/dist/svg/SvgNode.d.ts +0 -13
  93. package/dist/svg/SvgNode.js +0 -18
  94. package/dist/svg/SvgRenderer.d.ts +0 -22
  95. package/dist/svg/SvgRenderer.js +0 -20
  96. package/dist/svg/camera.d.ts +0 -21
  97. package/dist/svg/camera.js +0 -43
  98. package/dist/svg/index.d.ts +0 -6
  99. package/dist/svg/index.js +0 -6
  100. package/dist/svg/layers.d.ts +0 -18
  101. package/dist/svg/layers.js +0 -13
  102. package/dist/svg/shapes.d.ts +0 -1089
  103. package/dist/svg/shapes.js +0 -119
package/dist/Color.js ADDED
@@ -0,0 +1,535 @@
1
+ import chroma from "chroma-js";
2
+ import { Schema } from "effect";
3
+ import * as Function from "effect/Function";
4
+ import * as Pipeable from "effect/Pipeable";
5
+ const clamp = (value, minimum, maximum) => Math.min(Math.max(value, minimum), maximum);
6
+ export class Color extends Schema.TaggedClass()("Color", {
7
+ "~r": Schema.Number,
8
+ "~g": Schema.Number,
9
+ "~b": Schema.Number,
10
+ "~a": Schema.Number,
11
+ }) {
12
+ static of(r, g, b, a) {
13
+ return new Color({
14
+ "~r": clamp(r, 0, 255),
15
+ "~g": clamp(g, 0, 255),
16
+ "~b": clamp(b, 0, 255),
17
+ "~a": clamp(a ?? 1, 0, 1),
18
+ });
19
+ }
20
+ get r() {
21
+ return clamp(this["~r"], 0, 255);
22
+ }
23
+ get g() {
24
+ return clamp(this["~g"], 0, 255);
25
+ }
26
+ get b() {
27
+ return clamp(this["~b"], 0, 255);
28
+ }
29
+ get a() {
30
+ return clamp(this["~a"], 0, 1);
31
+ }
32
+ pipe = (..._fns) => {
33
+ return Pipeable.pipeArguments(this, _fns);
34
+ };
35
+ }
36
+ const toChroma = (color) => {
37
+ return chroma.rgb(color["~r"], color["~g"], color["~b"], color["~a"]);
38
+ };
39
+ const fromChroma = (color) => {
40
+ return new Color({
41
+ "~r": color._rgb._unclipped[0],
42
+ "~g": color._rgb._unclipped[1],
43
+ "~b": color._rgb._unclipped[2],
44
+ "~a": color._rgb._unclipped[3],
45
+ });
46
+ };
47
+ export const is = (value) => {
48
+ return value instanceof Color;
49
+ };
50
+ export const rgba = (r, g, b, alpha) => Color.of(r, g, b, alpha);
51
+ /** Parse a CSS color string (`#rgb`, `#rrggbb`, `#rrggbbaa`, named, `rgb()`, …). */
52
+ export const hex = (value) => {
53
+ const c = chroma(value);
54
+ const [r, g, b] = c.rgb();
55
+ return Color.of(r, g, b, c.alpha());
56
+ };
57
+ export const hsl = (h, s, l, alpha) => {
58
+ const rgb = chroma.hsl(h, s, l, alpha);
59
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
60
+ };
61
+ export const hsv = (h, s, v, alpha) => {
62
+ const rgb = chroma.hsv(h, s, v, alpha);
63
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
64
+ };
65
+ export const lab = (l, a, b, alpha) => {
66
+ const rgb = chroma.lab(l, a, b, alpha);
67
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
68
+ };
69
+ export const lch = (l, c, h, a) => {
70
+ const rgb = chroma.lch(l, c, h, a);
71
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
72
+ };
73
+ export const hcl = (h, c, l, a) => {
74
+ const rgb = chroma.hcl(h, c, l, a);
75
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
76
+ };
77
+ export const oklab = (l, a, b, alpha) => {
78
+ const rgb = chroma.oklab(l, a, b, alpha);
79
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
80
+ };
81
+ export const oklch = (l, c, h, alpha) => {
82
+ const rgb = chroma.oklch(l, c, h, alpha);
83
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
84
+ };
85
+ export const cmyk = (c, m, y, k) => {
86
+ const rgb = chroma.cmyk(c, m, y, k);
87
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
88
+ };
89
+ export const gl = (g, l, r, alpha) => {
90
+ const rgb = chroma.gl(g, l, r, alpha);
91
+ return Color.of(rgb._rgb._unclipped[0], rgb._rgb._unclipped[1], rgb._rgb._unclipped[2], rgb._rgb._unclipped[3]);
92
+ };
93
+ const secondIsColor = (args) => is(args[1]);
94
+ const firstIsColor = (args) => is(args[0]);
95
+ export const alpha = Function.dual(firstIsColor, (self, amount) => {
96
+ return new Color({
97
+ "~r": self["~r"],
98
+ "~g": self["~g"],
99
+ "~b": self["~b"],
100
+ "~a": amount,
101
+ });
102
+ });
103
+ export const darken = Function.dual(firstIsColor, (self, amount) => {
104
+ return fromChroma(toChroma(self).darken(amount));
105
+ });
106
+ export const brighten = Function.dual(firstIsColor, (self, amount) => {
107
+ return fromChroma(toChroma(self).brighten(amount));
108
+ });
109
+ export const saturate = Function.dual(firstIsColor, (self, amount) => {
110
+ return fromChroma(toChroma(self).saturate(amount));
111
+ });
112
+ export const desaturate = Function.dual(firstIsColor, (self, amount) => {
113
+ return fromChroma(toChroma(self).desaturate(amount));
114
+ });
115
+ export const mix = Function.dual(secondIsColor, (self, color, amount, mode) => {
116
+ const colorMix = chroma.mix(toChroma(self), toChroma(color), amount, mode);
117
+ return fromChroma(colorMix);
118
+ });
119
+ export const shade = Function.dual(firstIsColor, (self, amount, mode) => {
120
+ return fromChroma(toChroma(self).shade(amount, mode));
121
+ });
122
+ export const tint = Function.dual(firstIsColor, (self, amount, mode) => {
123
+ return fromChroma(toChroma(self).tint(amount, mode));
124
+ });
125
+ export const set = Function.dual(firstIsColor, (self, format, channel, amount) => {
126
+ return fromChroma(toChroma(self).set(`${format}.${channel}`, amount));
127
+ });
128
+ export const get = Function.dual(firstIsColor, (self, format, channel) => {
129
+ return toChroma(self).get(`${format}.${channel}`);
130
+ });
131
+ export const luminance = (self) => {
132
+ return toChroma(self).luminance();
133
+ };
134
+ export const temperature = (self) => {
135
+ return toChroma(self).temperature();
136
+ };
137
+ export const contrast = Function.dual(secondIsColor, (self, color) => {
138
+ return chroma.contrast(toChroma(self), toChroma(color));
139
+ });
140
+ export const contrastAPCA = Function.dual(secondIsColor, (self, color) => {
141
+ return chroma.contrastAPCA(toChroma(self), toChroma(color));
142
+ });
143
+ export const distance = Function.dual(secondIsColor, (self, color, format) => {
144
+ return chroma.distance(toChroma(self), toChroma(color), format);
145
+ });
146
+ export const deltaE = Function.dual(secondIsColor, (self, color, kl, kc, kh) => {
147
+ return chroma.deltaE(toChroma(self), toChroma(color), kl, kc, kh);
148
+ });
149
+ export const toHex = (self) => {
150
+ return toChroma(self).hex();
151
+ };
152
+ export const toRgb = (self) => {
153
+ return toChroma(self).rgb();
154
+ };
155
+ export const toHsl = (self) => {
156
+ return toChroma(self).hsl();
157
+ };
158
+ export const toHsv = (self) => {
159
+ return toChroma(self).hsv();
160
+ };
161
+ export const toOklab = (self) => {
162
+ return toChroma(self).oklab();
163
+ };
164
+ export const toOklch = (self) => {
165
+ return toChroma(self).oklch();
166
+ };
167
+ export const toNum = (self) => {
168
+ return toChroma(self).num();
169
+ };
170
+ export const blend = Function.dual(secondIsColor, (self, color, mode) => {
171
+ return fromChroma(chroma.blend(toChroma(self), toChroma(color), mode));
172
+ });
173
+ /**
174
+ * RGBA as 0–255 bytes — the form ThorVG's setFillColor/setStrokeColor want.
175
+ * `a` is scaled from the 0–1 alpha, so this is the single conversion point
176
+ * for the raster boundary (the getters keep alpha 0–1 for authoring math).
177
+ */
178
+ export const bytes = (self) => ({
179
+ r: Math.round(self.r),
180
+ g: Math.round(self.g),
181
+ b: Math.round(self.b),
182
+ a: Math.round(self.a * 255),
183
+ });
184
+ export const black = rgba(0, 0, 0, 1);
185
+ export const white = rgba(255, 255, 255, 1);
186
+ export const transparent = rgba(0, 0, 0, 0);
187
+ export const twMap = {
188
+ slate: {
189
+ "50": oklch(0.977, 0.017, 320.058),
190
+ "100": oklch(0.952, 0.037, 318.852),
191
+ "200": oklch(0.903, 0.076, 319.62),
192
+ "300": oklch(0.833, 0.145, 321.434),
193
+ "400": oklch(0.74, 0.238, 322.16),
194
+ "500": oklch(0.667, 0.295, 322.15),
195
+ "600": oklch(0.591, 0.293, 322.896),
196
+ "700": oklch(0.518, 0.253, 323.949),
197
+ "800": oklch(0.452, 0.211, 324.591),
198
+ "900": oklch(0.401, 0.17, 325.612),
199
+ "950": oklch(0.293, 0.136, 325.661),
200
+ },
201
+ gray: {
202
+ "50": oklch(0.985, 0, 247.839),
203
+ "100": oklch(0.967, 0.003, 264.542),
204
+ "200": oklch(0.928, 0.006, 264.531),
205
+ "300": oklch(0.872, 0.01, 258.338),
206
+ "400": oklch(Math.SQRT1_2, 0.022, 261.325),
207
+ "500": oklch(0.551, 0.027, 264.364),
208
+ "600": oklch(0.446, 0.03, 256.802),
209
+ "700": oklch(0.373, 0.034, 259.733),
210
+ "800": oklch(0.278, 0.033, 256.848),
211
+ "900": oklch(0.21, 0.034, 264.665),
212
+ "950": oklch(0.13, 0.028, 261.692),
213
+ },
214
+ zinc: {
215
+ "50": oklch(0.985, 0, 0),
216
+ "100": oklch(0.967, 0.001, 286.375),
217
+ "200": oklch(0.92, 0.004, 286.32),
218
+ "300": oklch(0.871, 0.006, 286.286),
219
+ "400": oklch(0.705, 0.015, 286.067),
220
+ "500": oklch(0.552, 0.016, 285.938),
221
+ "600": oklch(0.442, 0.017, 285.786),
222
+ "700": oklch(0.37, 0.013, 285.805),
223
+ "800": oklch(0.274, 0.006, 286.033),
224
+ "900": oklch(0.21, 0.006, 285.885),
225
+ "950": oklch(0.141, 0.005, 285.823),
226
+ },
227
+ neutral: {
228
+ "50": oklch(0.985, 0, 0),
229
+ "100": oklch(0.97, 0, 0),
230
+ "200": oklch(0.922, 0, 0),
231
+ "300": oklch(0.87, 0, 0),
232
+ "400": oklch(0.708, 0, 0),
233
+ "500": oklch(0.556, 0, 0),
234
+ "600": oklch(0.439, 0, 0),
235
+ "700": oklch(0.371, 0, 0),
236
+ "800": oklch(0.269, 0, 0),
237
+ "900": oklch(0.205, 0, 0),
238
+ "950": oklch(0.145, 0, 0),
239
+ },
240
+ stone: {
241
+ "50": oklch(0.985, 0.001, 106.423),
242
+ "100": oklch(0.97, 0.001, 106.424),
243
+ "200": oklch(0.923, 0.003, 48.717),
244
+ "300": oklch(0.869, 0.005, 56.366),
245
+ "400": oklch(0.709, 0.01, 56.259),
246
+ "500": oklch(0.553, 0.013, 58.071),
247
+ "600": oklch(0.444, 0.011, 73.639),
248
+ "700": oklch(0.374, 0.01, 67.558),
249
+ "800": oklch(0.268, 0.007, 34.298),
250
+ "900": oklch(0.216, 0.006, 56.043),
251
+ "950": oklch(0.147, 0.004, 49.25),
252
+ },
253
+ mauve: {
254
+ "50": oklch(0.985, 0, 0),
255
+ "100": oklch(0.96, 0.003, 325.6),
256
+ "200": oklch(0.922, 0.005, 325.62),
257
+ "300": oklch(0.865, 0.012, 325.68),
258
+ "400": oklch(0.711, 0.019, 323.02),
259
+ "500": oklch(0.542, 0.034, 322.5),
260
+ "600": oklch(0.435, 0.029, 321.78),
261
+ "700": oklch(0.364, 0.029, 323.89),
262
+ "800": oklch(0.263, 0.024, 320.12),
263
+ "900": oklch(0.212, 0.019, 322.12),
264
+ "950": oklch(0.145, 0.008, 326),
265
+ },
266
+ olive: {
267
+ "50": oklch(0.988, 0.003, 106.5),
268
+ "100": oklch(0.966, 0.005, 106.5),
269
+ "200": oklch(0.93, 0.007, 106.5),
270
+ "300": oklch(0.88, 0.011, 106.6),
271
+ "400": oklch(0.737, 0.021, 106.9),
272
+ "500": oklch(0.58, 0.031, 107.3),
273
+ "600": oklch(0.466, 0.025, 107.3),
274
+ "700": oklch(0.394, 0.023, 107.4),
275
+ "800": oklch(0.286, 0.016, 107.4),
276
+ "900": oklch(0.228, 0.013, 107.4),
277
+ "950": oklch(0.153, 0.006, 107.1),
278
+ },
279
+ mist: {
280
+ "50": oklch(0.987, 0.002, 197.1),
281
+ "100": oklch(0.963, 0.002, 197.1),
282
+ "200": oklch(0.925, 0.005, 214.3),
283
+ "300": oklch(0.872, 0.007, 219.6),
284
+ "400": oklch(0.723, 0.014, 214.4),
285
+ "500": oklch(0.56, 0.021, 213.5),
286
+ "600": oklch(0.45, 0.017, 213.2),
287
+ "700": oklch(0.378, 0.015, 216),
288
+ "800": oklch(0.275, 0.011, 216.9),
289
+ "900": oklch(0.218, 0.008, 223.9),
290
+ "950": oklch(0.148, 0.004, 228.8),
291
+ },
292
+ taupe: {
293
+ "50": oklch(0.986, 0.002, 67.8),
294
+ "100": oklch(0.96, 0.002, 17.2),
295
+ "200": oklch(0.922, 0.005, 34.3),
296
+ "300": oklch(0.868, 0.007, 39.5),
297
+ "400": oklch(0.714, 0.014, 41.2),
298
+ "500": oklch(0.547, 0.021, 43.1),
299
+ "600": oklch(0.438, 0.017, 39.3),
300
+ "700": oklch(0.367, 0.016, 35.7),
301
+ "800": oklch(0.268, 0.011, 36.5),
302
+ "900": oklch(0.214, 0.009, 43.1),
303
+ "950": oklch(0.147, 0.004, 49.3),
304
+ },
305
+ red: {
306
+ "50": oklch(0.971, 0.013, 17.38),
307
+ "100": oklch(0.936, 0.032, 17.717),
308
+ "200": oklch(0.885, 0.062, 18.334),
309
+ "300": oklch(0.808, 0.114, 19.571),
310
+ "400": oklch(0.704, 0.191, 22.216),
311
+ "500": oklch(0.637, 0.237, 25.331),
312
+ "600": oklch(0.577, 0.245, 27.325),
313
+ "700": oklch(0.505, 0.213, 27.518),
314
+ "800": oklch(0.444, 0.177, 26.899),
315
+ "900": oklch(0.396, 0.141, 25.723),
316
+ "950": oklch(0.258, 0.092, 26.042),
317
+ },
318
+ orange: {
319
+ "50": oklch(0.98, 0.016, 73.684),
320
+ "100": oklch(0.954, 0.038, 75.164),
321
+ "200": oklch(0.901, 0.076, 70.697),
322
+ "300": oklch(0.837, 0.128, 66.29),
323
+ "400": oklch(0.75, 0.183, 55.934),
324
+ "500": oklch(0.705, 0.213, 47.604),
325
+ "600": oklch(0.646, 0.222, 41.116),
326
+ "700": oklch(0.553, 0.195, 38.402),
327
+ "800": oklch(0.47, 0.157, 37.304),
328
+ "900": oklch(0.408, 0.123, 38.172),
329
+ "950": oklch(0.266, 0.079, 36.259),
330
+ },
331
+ amber: {
332
+ "50": oklch(0.987, 0.022, 95.277),
333
+ "100": oklch(0.962, 0.059, 95.617),
334
+ "200": oklch(0.924, 0.12, 95.746),
335
+ "300": oklch(0.879, 0.169, 91.605),
336
+ "400": oklch(0.828, 0.189, 84.429),
337
+ "500": oklch(0.769, 0.188, 70.08),
338
+ "600": oklch(0.666, 0.179, 58.318),
339
+ "700": oklch(0.555, 0.163, 48.998),
340
+ "800": oklch(0.473, 0.137, 46.201),
341
+ "900": oklch(0.414, 0.112, 45.904),
342
+ "950": oklch(0.279, 0.077, 45.635),
343
+ },
344
+ yellow: {
345
+ "50": oklch(0.987, 0.026, 102.212),
346
+ "100": oklch(0.973, 0.071, 103.193),
347
+ "200": oklch(0.945, 0.129, 101.54),
348
+ "300": oklch(0.905, 0.182, 98.111),
349
+ "400": oklch(0.852, 0.199, 91.936),
350
+ "500": oklch(0.795, 0.184, 86.047),
351
+ "600": oklch(0.681, 0.162, 75.834),
352
+ "700": oklch(0.554, 0.135, 66.442),
353
+ "800": oklch(0.476, 0.114, 61.907),
354
+ "900": oklch(0.421, 0.095, 57.708),
355
+ "950": oklch(0.286, 0.066, 53.813),
356
+ },
357
+ lime: {
358
+ "50": oklch(0.986, 0.031, 120.757),
359
+ "100": oklch(0.967, 0.067, 122.328),
360
+ "200": oklch(0.938, 0.127, 124.321),
361
+ "300": oklch(0.897, 0.196, 126.665),
362
+ "400": oklch(0.841, 0.238, 128.85),
363
+ "500": oklch(0.768, 0.233, 130.85),
364
+ "600": oklch(0.648, 0.2, 131.684),
365
+ "700": oklch(0.532, 0.157, 131.589),
366
+ "800": oklch(0.453, 0.124, 130.933),
367
+ "900": oklch(0.405, 0.101, 131.063),
368
+ "950": oklch(0.274, 0.072, 132.109),
369
+ },
370
+ green: {
371
+ "50": oklch(0.982, 0.018, 155.826),
372
+ "100": oklch(0.962, 0.044, 156.743),
373
+ "200": oklch(0.925, 0.084, 155.995),
374
+ "300": oklch(0.871, 0.15, 154.449),
375
+ "400": oklch(0.792, 0.209, 151.711),
376
+ "500": oklch(0.723, 0.219, 149.579),
377
+ "600": oklch(0.627, 0.194, 149.214),
378
+ "700": oklch(0.527, 0.154, 150.069),
379
+ "800": oklch(0.448, 0.119, 151.328),
380
+ "900": oklch(0.393, 0.095, 152.535),
381
+ "950": oklch(0.266, 0.065, 152.934),
382
+ },
383
+ emerald: {
384
+ "50": oklch(0.979, 0.021, 166.113),
385
+ "100": oklch(0.95, 0.052, 163.051),
386
+ "200": oklch(0.905, 0.093, 164.15),
387
+ "300": oklch(0.845, 0.143, 164.978),
388
+ "400": oklch(0.765, 0.177, 163.223),
389
+ "500": oklch(0.696, 0.17, 162.48),
390
+ "600": oklch(0.596, 0.145, 163.225),
391
+ "700": oklch(0.508, 0.118, 165.612),
392
+ "800": oklch(0.432, 0.095, 166.913),
393
+ "900": oklch(0.378, 0.077, 168.94),
394
+ "950": oklch(0.262, 0.051, 172.552),
395
+ },
396
+ teal: {
397
+ "50": oklch(0.984, 0.014, 180.72),
398
+ "100": oklch(0.953, 0.051, 180.801),
399
+ "200": oklch(0.91, 0.096, 180.426),
400
+ "300": oklch(0.855, 0.138, 181.071),
401
+ "400": oklch(0.777, 0.152, 181.912),
402
+ "500": oklch(0.704, 0.14, 182.503),
403
+ "600": oklch(0.6, 0.118, 184.704),
404
+ "700": oklch(0.511, 0.096, 186.391),
405
+ "800": oklch(0.437, 0.078, 188.216),
406
+ "900": oklch(0.386, 0.063, 188.416),
407
+ "950": oklch(0.277, 0.046, 192.524),
408
+ },
409
+ cyan: {
410
+ "50": oklch(0.984, 0.019, 200.873),
411
+ "100": oklch(0.956, 0.045, 203.388),
412
+ "200": oklch(0.917, 0.08, 205.041),
413
+ "300": oklch(0.865, 0.127, 207.078),
414
+ "400": oklch(0.789, 0.154, 211.53),
415
+ "500": oklch(0.715, 0.143, 215.221),
416
+ "600": oklch(0.609, 0.126, 221.723),
417
+ "700": oklch(0.52, 0.105, 223.128),
418
+ "800": oklch(0.45, 0.085, 224.283),
419
+ "900": oklch(0.398, 0.07, 227.392),
420
+ "950": oklch(0.302, 0.056, 229.695),
421
+ },
422
+ sky: {
423
+ "50": oklch(0.977, 0.013, 236.62),
424
+ "100": oklch(0.951, 0.026, 236.824),
425
+ "200": oklch(0.901, 0.058, 230.902),
426
+ "300": oklch(0.828, 0.111, 230.318),
427
+ "400": oklch(0.746, 0.16, 232.661),
428
+ "500": oklch(0.685, 0.169, 237.323),
429
+ "600": oklch(0.588, 0.158, 241.966),
430
+ "700": oklch(0.5, 0.134, 242.749),
431
+ "800": oklch(0.443, 0.11, 240.79),
432
+ "900": oklch(0.391, 0.09, 240.876),
433
+ "950": oklch(0.293, 0.066, 243.157),
434
+ },
435
+ blue: {
436
+ "50": oklch(0.97, 0.014, 254.604),
437
+ "100": oklch(0.932, 0.032, 255.585),
438
+ "200": oklch(0.882, 0.059, 254.128),
439
+ "300": oklch(0.809, 0.105, 251.813),
440
+ "400": oklch(Math.SQRT1_2, 0.165, 254.624),
441
+ "500": oklch(0.623, 0.214, 259.815),
442
+ "600": oklch(0.546, 0.245, 262.881),
443
+ "700": oklch(0.488, 0.243, 264.376),
444
+ "800": oklch(0.424, 0.199, 265.638),
445
+ "900": oklch(0.379, 0.146, 265.522),
446
+ "950": oklch(0.282, 0.091, 267.935),
447
+ },
448
+ indigo: {
449
+ "50": oklch(0.962, 0.018, 272.314),
450
+ "100": oklch(0.93, 0.034, 272.788),
451
+ "200": oklch(0.87, 0.065, 274.039),
452
+ "300": oklch(0.785, 0.115, 274.713),
453
+ "400": oklch(0.673, 0.182, 276.935),
454
+ "500": oklch(0.585, 0.233, 277.117),
455
+ "600": oklch(0.511, 0.262, 276.966),
456
+ "700": oklch(0.457, 0.24, 277.023),
457
+ "800": oklch(0.398, 0.195, 277.366),
458
+ "900": oklch(0.359, 0.144, 278.697),
459
+ "950": oklch(0.257, 0.09, 281.288),
460
+ },
461
+ violet: {
462
+ "50": oklch(0.969, 0.016, 293.756),
463
+ "100": oklch(0.943, 0.029, 294.588),
464
+ "200": oklch(0.894, 0.057, 293.283),
465
+ "300": oklch(0.811, 0.111, 293.571),
466
+ "400": oklch(0.702, 0.183, 293.541),
467
+ "500": oklch(0.606, 0.25, 292.717),
468
+ "600": oklch(0.541, 0.281, 293.009),
469
+ "700": oklch(0.491, 0.27, 292.581),
470
+ "800": oklch(0.432, 0.232, 292.759),
471
+ "900": oklch(0.38, 0.189, 293.745),
472
+ "950": oklch(0.283, 0.141, 291.089),
473
+ },
474
+ purple: {
475
+ "50": oklch(0.977, 0.014, 308.299),
476
+ "100": oklch(0.946, 0.033, 307.174),
477
+ "200": oklch(0.902, 0.063, 306.703),
478
+ "300": oklch(0.827, 0.119, 306.383),
479
+ "400": oklch(0.714, 0.203, 305.504),
480
+ "500": oklch(0.627, 0.265, 303.9),
481
+ "600": oklch(0.558, 0.288, 302.321),
482
+ "700": oklch(0.496, 0.265, 301.924),
483
+ "800": oklch(0.438, 0.218, 303.724),
484
+ "900": oklch(0.381, 0.176, 304.987),
485
+ "950": oklch(0.291, 0.149, 302.717),
486
+ },
487
+ fuchsia: {
488
+ "50": oklch(0.977, 0.017, 320.058),
489
+ "100": oklch(0.952, 0.037, 318.852),
490
+ "200": oklch(0.903, 0.076, 319.62),
491
+ "300": oklch(0.833, 0.145, 321.434),
492
+ "400": oklch(0.74, 0.238, 322.16),
493
+ "500": oklch(0.667, 0.295, 322.15),
494
+ "600": oklch(0.591, 0.293, 322.896),
495
+ "700": oklch(0.518, 0.253, 323.949),
496
+ "800": oklch(0.452, 0.211, 324.591),
497
+ "900": oklch(0.401, 0.17, 325.612),
498
+ "950": oklch(0.293, 0.136, 325.661),
499
+ },
500
+ pink: {
501
+ "50": oklch(0.971, 0.014, 343.198),
502
+ "100": oklch(0.948, 0.028, 342.258),
503
+ "200": oklch(0.899, 0.061, 343.231),
504
+ "300": oklch(0.823, 0.12, 346.018),
505
+ "400": oklch(0.718, 0.202, 349.761),
506
+ "500": oklch(0.656, 0.241, 354.308),
507
+ "600": oklch(0.592, 0.249, 0.584),
508
+ "700": oklch(0.525, 0.223, 3.958),
509
+ "800": oklch(0.459, 0.187, 3.815),
510
+ "900": oklch(0.408, 0.153, 2.432),
511
+ "950": oklch(0.284, 0.109, 3.907),
512
+ },
513
+ rose: {
514
+ "50": oklch(0.969, 0.015, 12.422),
515
+ "100": oklch(0.941, 0.03, 12.58),
516
+ "200": oklch(0.892, 0.058, 10.001),
517
+ "300": oklch(0.81, 0.117, 11.638),
518
+ "400": oklch(0.712, 0.194, 13.428),
519
+ "500": oklch(0.645, 0.246, 16.439),
520
+ "600": oklch(0.586, 0.253, 17.585),
521
+ "700": oklch(0.514, 0.222, 16.935),
522
+ "800": oklch(0.455, 0.188, 13.697),
523
+ "900": oklch(0.41, 0.159, 10.272),
524
+ "950": oklch(0.271, 0.105, 12.094),
525
+ },
526
+ };
527
+ export const tw = (color, shade = "400", alpha = 1) => {
528
+ const value = twMap[color][shade];
529
+ return new Color({
530
+ "~r": value["~r"],
531
+ "~g": value["~g"],
532
+ "~b": value["~b"],
533
+ "~a": alpha,
534
+ });
535
+ };
@@ -0,0 +1,10 @@
1
+ declare const EffectMotionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
2
+ readonly _tag: "EffectMotionError";
3
+ } & Readonly<A>;
4
+ export declare class EffectMotionError extends EffectMotionError_base<{
5
+ readonly message: string;
6
+ readonly cause: unknown;
7
+ }> {
8
+ static of(message: string, cause?: unknown): EffectMotionError;
9
+ }
10
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Data } from "effect";
2
+ export class EffectMotionError extends Data.TaggedError("EffectMotionError") {
3
+ static of(message, cause) {
4
+ return new EffectMotionError({ message, cause });
5
+ }
6
+ }
package/dist/Entity.d.ts CHANGED
@@ -12,29 +12,30 @@ export interface TraitLens<Data, Value> {
12
12
  readonly get: (data: Data) => Value;
13
13
  readonly set: (data: Data, value: Value) => Data;
14
14
  }
15
- /** a type alias (not interface) so it satisfies Record constraints */
15
+ /**
16
+ * a type alias (not interface) so it satisfies Record constraints.
17
+ * Position is 3D: `z` is depth (0 = the screen plane). 2D shapes default
18
+ * z to 0 and read as plain-2D; the camera projects x/y/z to screen.
19
+ */
16
20
  export type Position = {
17
21
  readonly x: number;
18
22
  readonly y: number;
23
+ readonly z: number;
19
24
  };
20
25
  export type EntityTraits<Data> = {
21
26
  readonly "~position": TraitLens<Data, Position>;
22
27
  readonly "~opacity": TraitLens<Data, number>;
23
28
  };
24
29
  export type TraitKey = keyof EntityTraits<unknown>;
25
- export interface Entity<Name extends string = string, Data extends Schema.Top = Schema.Top, Traits extends Partial<EntityTraits<Data["Type"]>> = {}, MakeInput = Data["~type.make.in"]> {
30
+ export interface Entity<Name extends string = string, Data extends Schema.Top = Schema.Top, Traits extends Partial<EntityTraits<Data["Type"]>> = {}> {
26
31
  readonly [TypeId]: typeof TypeId;
27
32
  readonly name: Name;
28
33
  readonly data: Data;
29
34
  readonly traits: Traits;
30
- make(input: MakeInput | Data["~type.make.in"]): Data["Type"];
31
- readonly _MakeInput?: MakeInput;
32
35
  }
33
- export type AnyEntity = Entity<any, any, any, any>;
36
+ export type AnyEntity = Entity<any, any, any>;
34
37
  /** the entity's trait lens, or a defect naming entity and trait */
35
38
  export declare const traitOrDie: <Data, Value>(entity: AnyEntity, key: TraitKey) => TraitLens<Data, Value>;
36
39
  type NormalizeStructLike<T extends Schema.Struct.Fields | AnyStructSchema> = T extends AnyStructSchema ? T : T extends Schema.Struct.Fields ? Schema.Struct<T> : never;
37
- export declare const make: <Name extends string, Data extends Schema.Struct.Fields | AnyStructSchema, const Traits extends Partial<EntityTraits<NormalizeStructLike<Data>["Type"]>> = {}, MakeInput = NormalizeStructLike<Data>["~type.make.in"]>(name: Name, data: Data, traits?: Traits, options?: {
38
- readonly normalize: (input: MakeInput | NormalizeStructLike<Data>["~type.make.in"]) => NormalizeStructLike<Data>["~type.make.in"];
39
- }) => Entity<Name, NormalizeStructLike<Data>, Traits, MakeInput>;
40
+ export declare const make: <Name extends string, Data extends Schema.Struct.Fields | AnyStructSchema, const Traits extends Partial<EntityTraits<NormalizeStructLike<Data>["Type"]>> = {}>(name: Name, data: Data, traits?: Traits) => Entity<Name, NormalizeStructLike<Data>, Traits>;
40
41
  export {};
package/dist/Entity.js CHANGED
@@ -11,7 +11,7 @@ export const traitOrDie = (entity, key) => {
11
11
  const normalizeStructLike = (data) => {
12
12
  return (Schema.isSchema(data) ? data : Schema.Struct(data));
13
13
  };
14
- export const make = (name, data, traits, options) => {
14
+ export const make = (name, data, traits) => {
15
15
  const normalized = normalizeStructLike(data);
16
16
  // `$` is reserved for builtin, engine-owned instance properties (e.g.
17
17
  // `$visible`), which live beside the data — never as entity-data fields.
@@ -25,8 +25,5 @@ export const make = (name, data, traits, options) => {
25
25
  name,
26
26
  data: normalized,
27
27
  traits: traits ?? {},
28
- make: (input) => normalized.make(options === undefined
29
- ? input
30
- : options.normalize(input)),
31
28
  };
32
29
  };
package/dist/Fonts.d.ts CHANGED
@@ -29,3 +29,13 @@ export declare const Fonts: Context.Reference<readonly FontResource[]>;
29
29
  export declare const get: (scene: {
30
30
  readonly annotations: Context.Context<never>;
31
31
  }) => ReadonlyArray<FontResource>;
32
+ /**
33
+ * A scene's declared fonts as a `family -> url` map for the ThorVG engine's
34
+ * `fonts` option. Only entries with a `src.url` are included — the ThorVG
35
+ * renderer fetches fonts by URL (no filesystem), so `path`-only entries are
36
+ * skipped. Merge this over the engine default so declared families load and a
37
+ * `sans-serif` entry can override the default sans.
38
+ */
39
+ export declare const urlMap: (scene: {
40
+ readonly annotations: Context.Context<never>;
41
+ }) => Record<string, string>;
package/dist/Fonts.js CHANGED
@@ -9,3 +9,19 @@ import * as Context from "effect/Context";
9
9
  export const Fonts = Context.Reference("motion/Fonts", { defaultValue: () => [] });
10
10
  /** A scene's declared fonts — empty for scenes never annotated. */
11
11
  export const get = (scene) => Context.get(scene.annotations, Fonts);
12
+ /**
13
+ * A scene's declared fonts as a `family -> url` map for the ThorVG engine's
14
+ * `fonts` option. Only entries with a `src.url` are included — the ThorVG
15
+ * renderer fetches fonts by URL (no filesystem), so `path`-only entries are
16
+ * skipped. Merge this over the engine default so declared families load and a
17
+ * `sans-serif` entry can override the default sans.
18
+ */
19
+ export const urlMap = (scene) => {
20
+ const out = {};
21
+ for (const font of get(scene)) {
22
+ if (font.src.url !== undefined) {
23
+ out[font.family] = font.src.url;
24
+ }
25
+ }
26
+ return out;
27
+ };
@@ -0,0 +1,33 @@
1
+ import * as Context from "effect/Context";
2
+ /**
3
+ * One loadable image asset. `name` is what `Shapes.Image` entities reference
4
+ * in their `image` field; `src` carries per-environment sources — browsers
5
+ * load `url`, file-based tooling may read `path` (reserved; url-only today,
6
+ * same contract as fonts). Consumers skip sources they can't use.
7
+ */
8
+ export interface ImageResource {
9
+ readonly name: string;
10
+ readonly src: {
11
+ readonly url?: string;
12
+ readonly path?: string;
13
+ };
14
+ }
15
+ /**
16
+ * Scene annotation key declaring the images a scene's Image entities depend
17
+ * on: `scene.annotate(Images.Images, [...])`. The runtime never reads it —
18
+ * decoded pixels cannot affect frame data. Consumers (the player, export
19
+ * tools) read it to load assets into their render session before playback.
20
+ */
21
+ export declare const Images: Context.Reference<readonly ImageResource[]>;
22
+ /** A scene's declared images — empty for scenes never annotated. */
23
+ export declare const get: (scene: {
24
+ readonly annotations: Context.Context<never>;
25
+ }) => ReadonlyArray<ImageResource>;
26
+ /**
27
+ * A scene's declared images as a `name -> url` map for the render session's
28
+ * `images` option. Only entries with a `src.url` are included — loading is
29
+ * fetch-by-URL (no filesystem), so `path`-only entries are skipped.
30
+ */
31
+ export declare const urlMap: (scene: {
32
+ readonly annotations: Context.Context<never>;
33
+ }) => Record<string, string>;