effect-motion 0.3.2 → 0.5.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 (91) hide show
  1. package/README.md +2 -2
  2. package/dist/Camera.d.ts +186 -49
  3. package/dist/Camera.js +343 -76
  4. package/dist/Color.d.ts +101 -1
  5. package/dist/Color.js +101 -1
  6. package/dist/EffectMotionError.d.ts +17 -0
  7. package/dist/EffectMotionError.js +17 -0
  8. package/dist/Entity.d.ts +682 -38
  9. package/dist/Entity.js +271 -27
  10. package/dist/Font.d.ts +108 -0
  11. package/dist/Font.js +95 -0
  12. package/dist/Image.d.ts +71 -0
  13. package/dist/Image.js +50 -0
  14. package/dist/Instance.d.ts +73 -11
  15. package/dist/Instance.js +44 -11
  16. package/dist/Motion.d.ts +328 -53
  17. package/dist/Motion.js +278 -46
  18. package/dist/Physics.d.ts +154 -20
  19. package/dist/Physics.js +92 -11
  20. package/dist/Projection.d.ts +37 -132
  21. package/dist/Projection.js +33 -292
  22. package/dist/Resource.d.ts +26 -0
  23. package/dist/Resource.js +41 -0
  24. package/dist/Runner.d.ts +653 -330
  25. package/dist/Runner.js +208 -158
  26. package/dist/Scene.d.ts +621 -171
  27. package/dist/Scene.js +620 -89
  28. package/dist/Timing.d.ts +170 -13
  29. package/dist/Timing.js +124 -6
  30. package/dist/Tree.d.ts +39 -0
  31. package/dist/Tree.js +127 -0
  32. package/dist/index.d.ts +54 -5
  33. package/dist/index.js +56 -5
  34. package/dist/particles/Particle.d.ts +2 -2
  35. package/dist/particles/ParticleField.d.ts +8 -6
  36. package/dist/particles/ParticleField.js +8 -9
  37. package/dist/particles/constructors.d.ts +5 -6
  38. package/dist/particles/constructors.js +8 -3
  39. package/dist/particles/legacy.d.ts +58 -0
  40. package/dist/particles/legacy.js +46 -0
  41. package/dist/particles/simulate.js +13 -5
  42. package/dist/particles/step.js +14 -10
  43. package/dist/types.d.ts +5 -0
  44. package/dist/types.js +1 -0
  45. package/package.json +2 -4
  46. package/dist/CameraHelpers.d.ts +0 -70
  47. package/dist/CameraHelpers.js +0 -239
  48. package/dist/CanvasExporter.d.ts +0 -12
  49. package/dist/CanvasExporter.js +0 -40
  50. package/dist/Fonts.d.ts +0 -41
  51. package/dist/Fonts.js +0 -27
  52. package/dist/Images.d.ts +0 -33
  53. package/dist/Images.js +0 -24
  54. package/dist/PngExporter.d.ts +0 -6
  55. package/dist/PngExporter.js +0 -85
  56. package/dist/Renderer.d.ts +0 -118
  57. package/dist/Renderer.js +0 -381
  58. package/dist/Shapes.d.ts +0 -11
  59. package/dist/Shapes.js +0 -11
  60. package/dist/demo.d.ts +0 -3
  61. package/dist/demo.js +0 -65
  62. package/dist/render/dof.d.ts +0 -27
  63. package/dist/render/dof.js +0 -37
  64. package/dist/render/paint.d.ts +0 -30
  65. package/dist/render/paint.js +0 -36
  66. package/dist/render/shapes.d.ts +0 -42
  67. package/dist/render/shapes.js +0 -310
  68. package/dist/shapes/Circle.d.ts +0 -32
  69. package/dist/shapes/Circle.js +0 -9
  70. package/dist/shapes/Ellipse.d.ts +0 -35
  71. package/dist/shapes/Ellipse.js +0 -10
  72. package/dist/shapes/Group.d.ts +0 -116
  73. package/dist/shapes/Group.js +0 -82
  74. package/dist/shapes/Hud.d.ts +0 -38
  75. package/dist/shapes/Hud.js +0 -35
  76. package/dist/shapes/Image.d.ts +0 -45
  77. package/dist/shapes/Image.js +0 -28
  78. package/dist/shapes/Line.d.ts +0 -47
  79. package/dist/shapes/Line.js +0 -35
  80. package/dist/shapes/Path.d.ts +0 -107
  81. package/dist/shapes/Path.js +0 -32
  82. package/dist/shapes/Rect.d.ts +0 -51
  83. package/dist/shapes/Rect.js +0 -22
  84. package/dist/shapes/Shape2D.d.ts +0 -49
  85. package/dist/shapes/Shape2D.js +0 -52
  86. package/dist/shapes/Shapes.d.ts +0 -11
  87. package/dist/shapes/Shapes.js +0 -11
  88. package/dist/shapes/Square.d.ts +0 -32
  89. package/dist/shapes/Square.js +0 -11
  90. package/dist/shapes/Text.d.ts +0 -51
  91. package/dist/shapes/Text.js +0 -24
@@ -1,45 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity.js";
3
- /**
4
- * A raster/vector image leaf. `image` names an asset declared via the
5
- * `Images` annotation; the render session decodes it once and every frame
6
- * reuses the decoded picture. An undeclared or failed asset paints nothing
7
- * (soft skip — the rest of the frame renders).
8
- *
9
- * `width`/`height` are optional and undefaulted: set BOTH to draw at that
10
- * size (numeric, so they tween); leave both absent to draw at the source's
11
- * natural size. A lone dimension is ignored (natural size used) — aspect
12
- * math would need the natural size, which frame data never sees.
13
- *
14
- * Billboard only: no orientation fields. ponytail: tilting an image needs a
15
- * projective setTransform (full 3×3, we hardcode the bottom row) mapping the
16
- * projected quad; add when a scene needs a tilted image.
17
- */
18
- export declare const Image: Entity.Entity<"shapes/Image", Schema.Struct<{
19
- x: Schema.withConstructorDefault<Schema.Number>;
20
- y: Schema.withConstructorDefault<Schema.Number>;
21
- z: Schema.withConstructorDefault<Schema.Number>;
22
- opacity: Schema.withConstructorDefault<Schema.Number>;
23
- image: Schema.String;
24
- width: Schema.optionalKey<Schema.Number>;
25
- height: Schema.optionalKey<Schema.Number>;
26
- }>, {
27
- readonly "~position": Entity.TraitLens<{
28
- readonly x: number;
29
- readonly y: number;
30
- readonly z: number;
31
- readonly opacity: number;
32
- readonly image: string;
33
- readonly width?: number;
34
- readonly height?: number;
35
- }, Entity.Position>;
36
- readonly "~opacity": Entity.TraitLens<{
37
- readonly x: number;
38
- readonly y: number;
39
- readonly z: number;
40
- readonly opacity: number;
41
- readonly image: string;
42
- readonly width?: number;
43
- readonly height?: number;
44
- }, number>;
45
- }>;
@@ -1,28 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity.js";
3
- import * as Shape2D from "./Shape2D.js";
4
- /**
5
- * A raster/vector image leaf. `image` names an asset declared via the
6
- * `Images` annotation; the render session decodes it once and every frame
7
- * reuses the decoded picture. An undeclared or failed asset paints nothing
8
- * (soft skip — the rest of the frame renders).
9
- *
10
- * `width`/`height` are optional and undefaulted: set BOTH to draw at that
11
- * size (numeric, so they tween); leave both absent to draw at the source's
12
- * natural size. A lone dimension is ignored (natural size used) — aspect
13
- * math would need the natural size, which frame data never sees.
14
- *
15
- * Billboard only: no orientation fields. ponytail: tilting an image needs a
16
- * projective setTransform (full 3×3, we hardcode the bottom row) mapping the
17
- * projected quad; add when a scene needs a tilted image.
18
- */
19
- export const Image = Entity.make("shapes/Image", {
20
- ...Shape2D.position,
21
- image: Schema.String,
22
- width: Schema.optionalKey(Schema.Number),
23
- height: Schema.optionalKey(Schema.Number),
24
- ...Shape2D.opacity,
25
- }, {
26
- "~position": Shape2D.positionLens(),
27
- "~opacity": Shape2D.opacityLens(),
28
- });
@@ -1,47 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Color from "../Color.js";
3
- import * as Entity from "../Entity.js";
4
- declare const fields: {
5
- x: Schema.withConstructorDefault<Schema.Number>;
6
- y: Schema.withConstructorDefault<Schema.Number>;
7
- z: Schema.withConstructorDefault<Schema.Number>;
8
- opacity: Schema.withConstructorDefault<Schema.Number>;
9
- x2: Schema.withConstructorDefault<Schema.Number>;
10
- y2: Schema.withConstructorDefault<Schema.Number>;
11
- z2: Schema.withConstructorDefault<Schema.Number>;
12
- stroke: Schema.withConstructorDefault<typeof Color.Color>;
13
- strokeWidth: Schema.withConstructorDefault<Schema.Number>;
14
- };
15
- type LineData = Schema.Struct<typeof fields>["Type"];
16
- export declare const Line: Entity.Entity<"shapes/Line", Schema.Struct<{
17
- x: Schema.withConstructorDefault<Schema.Number>;
18
- y: Schema.withConstructorDefault<Schema.Number>;
19
- z: Schema.withConstructorDefault<Schema.Number>;
20
- opacity: Schema.withConstructorDefault<Schema.Number>;
21
- x2: Schema.withConstructorDefault<Schema.Number>;
22
- y2: Schema.withConstructorDefault<Schema.Number>;
23
- z2: Schema.withConstructorDefault<Schema.Number>;
24
- stroke: Schema.withConstructorDefault<typeof Color.Color>;
25
- strokeWidth: Schema.withConstructorDefault<Schema.Number>;
26
- }>, {
27
- readonly "~position": {
28
- get: (data: LineData) => {
29
- x: number;
30
- y: number;
31
- z: number;
32
- };
33
- set: (data: LineData, value: Entity.Position) => LineData;
34
- };
35
- readonly "~opacity": Entity.TraitLens<Schema.Struct.ReadonlySide<{
36
- x: Schema.withConstructorDefault<Schema.Number>;
37
- y: Schema.withConstructorDefault<Schema.Number>;
38
- z: Schema.withConstructorDefault<Schema.Number>;
39
- opacity: Schema.withConstructorDefault<Schema.Number>;
40
- x2: Schema.withConstructorDefault<Schema.Number>;
41
- y2: Schema.withConstructorDefault<Schema.Number>;
42
- z2: Schema.withConstructorDefault<Schema.Number>;
43
- stroke: Schema.withConstructorDefault<typeof Color.Color>;
44
- strokeWidth: Schema.withConstructorDefault<Schema.Number>;
45
- }, "Type">, number>;
46
- }>;
47
- export {};
@@ -1,35 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Schema from "effect/Schema";
3
- import * as Color from "../Color.js";
4
- import * as Entity from "../Entity.js";
5
- import * as Shape2D from "./Shape2D.js";
6
- // No fill — a line is unfillable, so unlike the filled shapes it defaults
7
- // stroke white / strokeWidth 1: the visible default (see Shape2D.ts).
8
- // x/y/z is the start point, x2/y2/z2 the end point — a Line is skeletal:
9
- // each endpoint is an independent 3D world point (no orientation fields).
10
- const fields = {
11
- ...Shape2D.position,
12
- x2: Shape2D.defaultedNumber(0),
13
- y2: Shape2D.defaultedNumber(0),
14
- z2: Shape2D.defaultedNumber(0),
15
- stroke: Color.Color.pipe(Schema.withConstructorDefault(Effect.succeed(Color.white))),
16
- strokeWidth: Shape2D.defaultedNumber(1),
17
- ...Shape2D.opacity,
18
- };
19
- export const Line = Entity.make("shapes/Line", fields, {
20
- // position moves the WHOLE line: translating x/y/z alone would stretch
21
- // it, so set shifts both endpoints by the delta (get = start point)
22
- "~position": {
23
- get: (data) => ({ x: data.x, y: data.y, z: data.z }),
24
- set: (data, value) => ({
25
- ...data,
26
- x: value.x,
27
- y: value.y,
28
- z: value.z,
29
- x2: data.x2 + (value.x - data.x),
30
- y2: data.y2 + (value.y - data.y),
31
- z2: data.z2 + (value.z - data.z),
32
- }),
33
- },
34
- "~opacity": Shape2D.opacityLens(),
35
- });
@@ -1,107 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity.js";
3
- export declare const PathCommand: Schema.TaggedUnion<{
4
- readonly L: Schema.TaggedStruct<"L", {
5
- x: Schema.Number;
6
- y: Schema.Number;
7
- z: Schema.optionalKey<Schema.Number>;
8
- }>;
9
- readonly M: Schema.TaggedStruct<"M", {
10
- x: Schema.Number;
11
- y: Schema.Number;
12
- z: Schema.optionalKey<Schema.Number>;
13
- }>;
14
- readonly Z: Schema.TaggedStruct<"Z", {}>;
15
- }>;
16
- export type PathCommand = typeof PathCommand.Type;
17
- export declare const Path: Entity.Entity<"shapes/Path", Schema.Struct<{
18
- x: Schema.withConstructorDefault<Schema.Number>;
19
- y: Schema.withConstructorDefault<Schema.Number>;
20
- z: Schema.withConstructorDefault<Schema.Number>;
21
- opacity: Schema.withConstructorDefault<Schema.Number>;
22
- fill: Schema.withConstructorDefault<typeof import("../Color.js").Color>;
23
- stroke: Schema.optionalKey<typeof import("../Color.js").Color>;
24
- strokeWidth: Schema.optionalKey<Schema.Number>;
25
- commands: Schema.NonEmptyArray<Schema.TaggedUnion<{
26
- readonly L: Schema.TaggedStruct<"L", {
27
- x: Schema.Number;
28
- y: Schema.Number;
29
- z: Schema.optionalKey<Schema.Number>;
30
- }>;
31
- readonly M: Schema.TaggedStruct<"M", {
32
- x: Schema.Number;
33
- y: Schema.Number;
34
- z: Schema.optionalKey<Schema.Number>;
35
- }>;
36
- readonly Z: Schema.TaggedStruct<"Z", {}>;
37
- }>>;
38
- }>, {
39
- readonly "~position": Entity.TraitLens<{
40
- readonly x: number;
41
- readonly y: number;
42
- readonly z: number;
43
- readonly opacity: number;
44
- readonly fill: import("../Color.js").Color;
45
- readonly stroke?: import("../Color.js").Color;
46
- readonly strokeWidth?: number;
47
- readonly commands: readonly [Schema.Struct.ReadonlySide<{
48
- readonly _tag: Schema.tag<"Z">;
49
- }, "Type"> | {
50
- readonly _tag: "L";
51
- readonly x: number;
52
- readonly y: number;
53
- readonly z?: number;
54
- } | {
55
- readonly _tag: "M";
56
- readonly x: number;
57
- readonly y: number;
58
- readonly z?: number;
59
- }, ...(Schema.Struct.ReadonlySide<{
60
- readonly _tag: Schema.tag<"Z">;
61
- }, "Type"> | {
62
- readonly _tag: "L";
63
- readonly x: number;
64
- readonly y: number;
65
- readonly z?: number;
66
- } | {
67
- readonly _tag: "M";
68
- readonly x: number;
69
- readonly y: number;
70
- readonly z?: number;
71
- })[]];
72
- }, Entity.Position>;
73
- readonly "~opacity": Entity.TraitLens<{
74
- readonly x: number;
75
- readonly y: number;
76
- readonly z: number;
77
- readonly opacity: number;
78
- readonly fill: import("../Color.js").Color;
79
- readonly stroke?: import("../Color.js").Color;
80
- readonly strokeWidth?: number;
81
- readonly commands: readonly [Schema.Struct.ReadonlySide<{
82
- readonly _tag: Schema.tag<"Z">;
83
- }, "Type"> | {
84
- readonly _tag: "L";
85
- readonly x: number;
86
- readonly y: number;
87
- readonly z?: number;
88
- } | {
89
- readonly _tag: "M";
90
- readonly x: number;
91
- readonly y: number;
92
- readonly z?: number;
93
- }, ...(Schema.Struct.ReadonlySide<{
94
- readonly _tag: Schema.tag<"Z">;
95
- }, "Type"> | {
96
- readonly _tag: "L";
97
- readonly x: number;
98
- readonly y: number;
99
- readonly z?: number;
100
- } | {
101
- readonly _tag: "M";
102
- readonly x: number;
103
- readonly y: number;
104
- readonly z?: number;
105
- })[]];
106
- }, number>;
107
- }>;
@@ -1,32 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity.js";
3
- import * as Shape2D from "./Shape2D.js";
4
- // A command point, LOCAL to the path's anchor (x/y/z). `z` is optionalKey
5
- // (absent = 0, coalesced at render): nested constructor defaults would not
6
- // fire through the entity struct's `make`, so absence is the default.
7
- const point = {
8
- x: Schema.Number,
9
- y: Schema.Number,
10
- z: Schema.optionalKey(Schema.Number),
11
- };
12
- // The command vocabulary: M (move to) starts a subpath, L (line to) extends
13
- // it, Z closes it. Straight polylines only — curves/arcs arrive in a later
14
- // iteration via deterministic flattening.
15
- export const PathCommand = Schema.TaggedUnion({
16
- M: point,
17
- L: point,
18
- Z: {},
19
- });
20
- // `commands` is required — an empty path can never be visible, so there is
21
- // no sensible default. Points are local to the anchor: the ~position trait
22
- // moves the anchor and never rewrites the array. The first command must be
23
- // M (every subpath needs a start point) — a loud failure at instantiation.
24
- export const Path = Entity.make("shapes/Path", {
25
- ...Shape2D.filled,
26
- commands: Schema.NonEmptyArray(PathCommand).check(Schema.makeFilter((commands) => commands[0]._tag === "M"
27
- ? undefined
28
- : { path: [0], issue: "the first path command must be M" })),
29
- }, {
30
- "~position": Shape2D.positionLens(),
31
- "~opacity": Shape2D.opacityLens(),
32
- });
@@ -1,51 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity.js";
3
- export declare const Rect: Entity.Entity<"shapes/Rect", Schema.Struct<{
4
- x: Schema.withConstructorDefault<Schema.Number>;
5
- y: Schema.withConstructorDefault<Schema.Number>;
6
- z: Schema.withConstructorDefault<Schema.Number>;
7
- rotX: Schema.withConstructorDefault<Schema.Number>;
8
- rotY: Schema.withConstructorDefault<Schema.Number>;
9
- rotZ: Schema.withConstructorDefault<Schema.Number>;
10
- opacity: Schema.withConstructorDefault<Schema.Number>;
11
- fill: Schema.withConstructorDefault<typeof import("../Color.js").Color>;
12
- stroke: Schema.optionalKey<typeof import("../Color.js").Color>;
13
- strokeWidth: Schema.optionalKey<Schema.Number>;
14
- width: Schema.withConstructorDefault<Schema.Number>;
15
- height: Schema.withConstructorDefault<Schema.Number>;
16
- rx: Schema.optionalKey<Schema.Number>;
17
- ry: Schema.optionalKey<Schema.Number>;
18
- }>, {
19
- readonly "~position": Entity.TraitLens<{
20
- readonly x: number;
21
- readonly y: number;
22
- readonly z: number;
23
- readonly rotX: number;
24
- readonly rotY: number;
25
- readonly rotZ: number;
26
- readonly opacity: number;
27
- readonly fill: import("../Color.js").Color;
28
- readonly stroke?: import("../Color.js").Color;
29
- readonly strokeWidth?: number;
30
- readonly width: number;
31
- readonly height: number;
32
- readonly rx?: number;
33
- readonly ry?: number;
34
- }, Entity.Position>;
35
- readonly "~opacity": Entity.TraitLens<{
36
- readonly x: number;
37
- readonly y: number;
38
- readonly z: number;
39
- readonly rotX: number;
40
- readonly rotY: number;
41
- readonly rotZ: number;
42
- readonly opacity: number;
43
- readonly fill: import("../Color.js").Color;
44
- readonly stroke?: import("../Color.js").Color;
45
- readonly strokeWidth?: number;
46
- readonly width: number;
47
- readonly height: number;
48
- readonly rx?: number;
49
- readonly ry?: number;
50
- }, number>;
51
- }>;
@@ -1,22 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity.js";
3
- import * as Shape2D from "./Shape2D.js";
4
- // A Rect is the canonical 2.5D plane: give it Euler orientation so it can
5
- // tilt in 3D (lie flat as a floor, tilt as a wall). All-zero rotation (the
6
- // default) keeps it a camera-facing billboard. The renderer projects its
7
- // four corners when tilted (see Renderer flatten + Projection.planeCorners).
8
- //
9
- // `rx`/`ry` round the corners (SVG semantics: a lone radius applies to both
10
- // axes); numeric, so they tween. A TILTED rect ignores them — the tilt path
11
- // paints an exact projected polygon, which can't express rounding.
12
- export const Rect = Entity.make("shapes/Rect", {
13
- ...Shape2D.filled,
14
- ...Shape2D.orientation,
15
- width: Shape2D.defaultedNumber(100),
16
- height: Shape2D.defaultedNumber(100),
17
- rx: Schema.optionalKey(Schema.Number),
18
- ry: Schema.optionalKey(Schema.Number),
19
- }, {
20
- "~position": Shape2D.positionLens(),
21
- "~opacity": Shape2D.opacityLens(),
22
- });
@@ -1,49 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Color from "../Color.js";
3
- import type * as Entity from "../Entity.js";
4
- /**
5
- * The portable styling prop set shared by built-in shapes — deliberately
6
- * limited to what any plausible render target (SVG, canvas, Lottie) can
7
- * express. Camera pan/zoom is a sink-level view transform (see Camera.ts);
8
- * per-shape transforms (rotation) remain future territory.
9
- *
10
- * Visible defaults: a default-constructed shape must be visible on the
11
- * default (dark) background. Filled shapes default `fill` to white with
12
- * stroke absent; Line overrides this (stroke white, width 1 — see
13
- * Line.ts). Absent optional props are omitted by render targets, never
14
- * emitted with placeholder values.
15
- */
16
- export declare const defaultedNumber: (value: number) => Schema.withConstructorDefault<Schema.Number>;
17
- export declare const position: {
18
- x: Schema.withConstructorDefault<Schema.Number>;
19
- y: Schema.withConstructorDefault<Schema.Number>;
20
- z: Schema.withConstructorDefault<Schema.Number>;
21
- };
22
- export declare const orientation: {
23
- rotX: Schema.withConstructorDefault<Schema.Number>;
24
- rotY: Schema.withConstructorDefault<Schema.Number>;
25
- rotZ: Schema.withConstructorDefault<Schema.Number>;
26
- };
27
- export declare const opacity: {
28
- opacity: Schema.withConstructorDefault<Schema.Number>;
29
- };
30
- /** Common fields for fillable shapes. */
31
- export declare const filled: {
32
- x: Schema.withConstructorDefault<Schema.Number>;
33
- y: Schema.withConstructorDefault<Schema.Number>;
34
- z: Schema.withConstructorDefault<Schema.Number>;
35
- opacity: Schema.withConstructorDefault<Schema.Number>;
36
- fill: Schema.withConstructorDefault<typeof Color.Color>;
37
- stroke: Schema.optionalKey<typeof Color.Color>;
38
- strokeWidth: Schema.optionalKey<Schema.Number>;
39
- };
40
- /** standard x/y/z position lens for shapes whose position IS x/y/z */
41
- export declare const positionLens: <Data extends {
42
- x: number;
43
- y: number;
44
- z: number;
45
- }>() => Entity.TraitLens<Data, Entity.Position>;
46
- /** standard opacity lens */
47
- export declare const opacityLens: <Data extends {
48
- opacity: number;
49
- }>() => Entity.TraitLens<Data, number>;
@@ -1,52 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Schema from "effect/Schema";
3
- import * as Color from "../Color.js";
4
- /**
5
- * The portable styling prop set shared by built-in shapes — deliberately
6
- * limited to what any plausible render target (SVG, canvas, Lottie) can
7
- * express. Camera pan/zoom is a sink-level view transform (see Camera.ts);
8
- * per-shape transforms (rotation) remain future territory.
9
- *
10
- * Visible defaults: a default-constructed shape must be visible on the
11
- * default (dark) background. Filled shapes default `fill` to white with
12
- * stroke absent; Line overrides this (stroke white, width 1 — see
13
- * Line.ts). Absent optional props are omitted by render targets, never
14
- * emitted with placeholder values.
15
- */
16
- export const defaultedNumber = (value) => Schema.Number.pipe(Schema.withConstructorDefault(Effect.succeed(value)));
17
- // z is depth (0 = the screen plane); a default-constructed shape sits at
18
- // z=0 and projects to plain-2D coordinates under the resting camera.
19
- export const position = {
20
- x: defaultedNumber(0),
21
- y: defaultedNumber(0),
22
- z: defaultedNumber(0),
23
- };
24
- // Euler orientation for a shape's plane. All-zero (the default) is a
25
- // billboard facing the camera; non-zero tilts the plane in 3D.
26
- export const orientation = {
27
- rotX: defaultedNumber(0),
28
- rotY: defaultedNumber(0),
29
- rotZ: defaultedNumber(0),
30
- };
31
- export const opacity = {
32
- opacity: defaultedNumber(1),
33
- };
34
- /** Common fields for fillable shapes. */
35
- export const filled = {
36
- ...position,
37
- fill: Color.Color.pipe(Schema.withConstructorDefault(Effect.succeed(Color.white))),
38
- stroke: Schema.optionalKey(Color.Color),
39
- strokeWidth: Schema.optionalKey(Schema.Number),
40
- ...opacity,
41
- };
42
- /** standard x/y/z position lens for shapes whose position IS x/y/z */
43
- export const positionLens = () => ({
44
- get: (data) => ({ x: data.x, y: data.y, z: data.z }),
45
- // spread of a generic yields Data & {...}; assignable back to Data
46
- set: (data, value) => ({ ...data, x: value.x, y: value.y, z: value.z }),
47
- });
48
- /** standard opacity lens */
49
- export const opacityLens = () => ({
50
- get: (data) => data.opacity,
51
- set: (data, opacity) => ({ ...data, opacity }),
52
- });
@@ -1,11 +0,0 @@
1
- export { Circle } from "./Circle.js";
2
- export { Ellipse } from "./Ellipse.js";
3
- export * from "./Group.js";
4
- export { Hud } from "./Hud.js";
5
- export { Image } from "./Image.js";
6
- export { Line } from "./Line.js";
7
- export { Path } from "./Path.js";
8
- export { Rect } from "./Rect.js";
9
- export * as Shape2D from "./Shape2D.js";
10
- export { Square } from "./Square.js";
11
- export { Text } from "./Text.js";
@@ -1,11 +0,0 @@
1
- export { Circle } from "./Circle.js";
2
- export { Ellipse } from "./Ellipse.js";
3
- export * from "./Group.js";
4
- export { Hud } from "./Hud.js";
5
- export { Image } from "./Image.js";
6
- export { Line } from "./Line.js";
7
- export { Path } from "./Path.js";
8
- export { Rect } from "./Rect.js";
9
- export * as Shape2D from "./Shape2D.js";
10
- export { Square } from "./Square.js";
11
- export { Text } from "./Text.js";
@@ -1,32 +0,0 @@
1
- import * as Entity from "../Entity.js";
2
- export declare const Square: Entity.Entity<"shapes/Square", import("effect/Schema").Struct<{
3
- x: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
4
- y: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
5
- z: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
6
- opacity: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
7
- fill: import("effect/Schema").withConstructorDefault<typeof import("../Color.js").Color>;
8
- stroke: import("effect/Schema").optionalKey<typeof import("../Color.js").Color>;
9
- strokeWidth: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
10
- size: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
11
- }>, {
12
- readonly "~position": Entity.TraitLens<{
13
- readonly x: number;
14
- readonly y: number;
15
- readonly z: number;
16
- readonly opacity: number;
17
- readonly fill: import("../Color.js").Color;
18
- readonly stroke?: import("../Color.js").Color;
19
- readonly strokeWidth?: number;
20
- readonly size: number;
21
- }, Entity.Position>;
22
- readonly "~opacity": Entity.TraitLens<{
23
- readonly x: number;
24
- readonly y: number;
25
- readonly z: number;
26
- readonly opacity: number;
27
- readonly fill: import("../Color.js").Color;
28
- readonly stroke?: import("../Color.js").Color;
29
- readonly strokeWidth?: number;
30
- readonly size: number;
31
- }, number>;
32
- }>;
@@ -1,11 +0,0 @@
1
- import * as Entity from "../Entity.js";
2
- import * as Shape2D from "./Shape2D.js";
3
- // its own entity, not Rect sugar: the schema IS the width === height
4
- // constraint, which a Rect can't enforce through updates
5
- export const Square = Entity.make("shapes/Square", {
6
- ...Shape2D.filled,
7
- size: Shape2D.defaultedNumber(100),
8
- }, {
9
- "~position": Shape2D.positionLens(),
10
- "~opacity": Shape2D.opacityLens(),
11
- });
@@ -1,51 +0,0 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity.js";
3
- /**
4
- * A plain-string text leaf. `text` is required. The engine cannot measure
5
- * text, so alignment is delegated to SVG via `textAnchor` / `baseline`.
6
- * Inline formatting and multi-run styling are expressed by composing
7
- * multiple `Text` instances (via `children`), not by an in-engine tree.
8
- */
9
- export declare const Text: Entity.Entity<"shapes/Text", Schema.Struct<{
10
- x: Schema.withConstructorDefault<Schema.Number>;
11
- y: Schema.withConstructorDefault<Schema.Number>;
12
- z: Schema.withConstructorDefault<Schema.Number>;
13
- opacity: Schema.withConstructorDefault<Schema.Number>;
14
- fill: Schema.withConstructorDefault<typeof import("../Color.js").Color>;
15
- stroke: Schema.optionalKey<typeof import("../Color.js").Color>;
16
- strokeWidth: Schema.optionalKey<Schema.Number>;
17
- text: Schema.String;
18
- fontSize: Schema.withConstructorDefault<Schema.Number>;
19
- fontFamily: Schema.withConstructorDefault<Schema.String>;
20
- textAnchor: Schema.optionalKey<Schema.Literals<readonly ["start", "middle", "end"]>>;
21
- baseline: Schema.optionalKey<Schema.Literals<readonly ["auto", "middle", "hanging"]>>;
22
- }>, {
23
- readonly "~position": Entity.TraitLens<{
24
- readonly x: number;
25
- readonly y: number;
26
- readonly z: number;
27
- readonly opacity: number;
28
- readonly fill: import("../Color.js").Color;
29
- readonly stroke?: import("../Color.js").Color;
30
- readonly strokeWidth?: number;
31
- readonly text: string;
32
- readonly fontSize: number;
33
- readonly fontFamily: string;
34
- readonly textAnchor?: "end" | "middle" | "start";
35
- readonly baseline?: "auto" | "hanging" | "middle";
36
- }, Entity.Position>;
37
- readonly "~opacity": Entity.TraitLens<{
38
- readonly x: number;
39
- readonly y: number;
40
- readonly z: number;
41
- readonly opacity: number;
42
- readonly fill: import("../Color.js").Color;
43
- readonly stroke?: import("../Color.js").Color;
44
- readonly strokeWidth?: number;
45
- readonly text: string;
46
- readonly fontSize: number;
47
- readonly fontFamily: string;
48
- readonly textAnchor?: "end" | "middle" | "start";
49
- readonly baseline?: "auto" | "hanging" | "middle";
50
- }, number>;
51
- }>;
@@ -1,24 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import * as Schema from "effect/Schema";
3
- import * as Entity from "../Entity.js";
4
- import * as Shape2D from "./Shape2D.js";
5
- /**
6
- * A plain-string text leaf. `text` is required. The engine cannot measure
7
- * text, so alignment is delegated to SVG via `textAnchor` / `baseline`.
8
- * Inline formatting and multi-run styling are expressed by composing
9
- * multiple `Text` instances (via `children`), not by an in-engine tree.
10
- */
11
- export const Text = Entity.make("shapes/Text", {
12
- ...Shape2D.filled,
13
- text: Schema.String,
14
- // numeric, therefore tweenable: tweenTo({ fontSize }) just works
15
- fontSize: Shape2D.defaultedNumber(16),
16
- // the generic family resolves to a sane system sans on every
17
- // platform — no bet on a named font existing
18
- fontFamily: Schema.String.pipe(Schema.withConstructorDefault(Effect.succeed("sans-serif"))),
19
- textAnchor: Schema.optionalKey(Schema.Literals(["start", "middle", "end"])),
20
- baseline: Schema.optionalKey(Schema.Literals(["auto", "middle", "hanging"])),
21
- }, {
22
- "~position": Shape2D.positionLens(),
23
- "~opacity": Shape2D.opacityLens(),
24
- });