effect-motion 0.2.0 → 0.3.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 (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 +13 -3
  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
@@ -0,0 +1,28 @@
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 +1,47 @@
1
1
  import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity";
2
+ import * as Color from "../Color.js";
3
+ import * as Entity from "../Entity.js";
3
4
  declare const fields: {
4
5
  x: Schema.withConstructorDefault<Schema.Number>;
5
6
  y: Schema.withConstructorDefault<Schema.Number>;
7
+ z: Schema.withConstructorDefault<Schema.Number>;
6
8
  opacity: Schema.withConstructorDefault<Schema.Number>;
7
9
  x2: Schema.withConstructorDefault<Schema.Number>;
8
10
  y2: Schema.withConstructorDefault<Schema.Number>;
9
- stroke: Schema.withConstructorDefault<Schema.String>;
11
+ z2: Schema.withConstructorDefault<Schema.Number>;
12
+ stroke: Schema.withConstructorDefault<typeof Color.Color>;
10
13
  strokeWidth: Schema.withConstructorDefault<Schema.Number>;
11
14
  };
12
15
  type LineData = Schema.Struct<typeof fields>["Type"];
13
16
  export declare const Line: Entity.Entity<"shapes/Line", Schema.Struct<{
14
17
  x: Schema.withConstructorDefault<Schema.Number>;
15
18
  y: Schema.withConstructorDefault<Schema.Number>;
19
+ z: Schema.withConstructorDefault<Schema.Number>;
16
20
  opacity: Schema.withConstructorDefault<Schema.Number>;
17
21
  x2: Schema.withConstructorDefault<Schema.Number>;
18
22
  y2: Schema.withConstructorDefault<Schema.Number>;
19
- stroke: Schema.withConstructorDefault<Schema.String>;
23
+ z2: Schema.withConstructorDefault<Schema.Number>;
24
+ stroke: Schema.withConstructorDefault<typeof Color.Color>;
20
25
  strokeWidth: Schema.withConstructorDefault<Schema.Number>;
21
26
  }>, {
22
27
  readonly "~position": {
23
28
  get: (data: LineData) => {
24
29
  x: number;
25
30
  y: number;
31
+ z: number;
26
32
  };
27
33
  set: (data: LineData, value: Entity.Position) => LineData;
28
34
  };
29
35
  readonly "~opacity": Entity.TraitLens<Schema.Struct.ReadonlySide<{
30
36
  x: Schema.withConstructorDefault<Schema.Number>;
31
37
  y: Schema.withConstructorDefault<Schema.Number>;
38
+ z: Schema.withConstructorDefault<Schema.Number>;
32
39
  opacity: Schema.withConstructorDefault<Schema.Number>;
33
40
  x2: Schema.withConstructorDefault<Schema.Number>;
34
41
  y2: Schema.withConstructorDefault<Schema.Number>;
35
- stroke: Schema.withConstructorDefault<Schema.String>;
42
+ z2: Schema.withConstructorDefault<Schema.Number>;
43
+ stroke: Schema.withConstructorDefault<typeof Color.Color>;
36
44
  strokeWidth: Schema.withConstructorDefault<Schema.Number>;
37
45
  }, "Type">, number>;
38
- }, {
39
- readonly x?: number;
40
- readonly y?: number;
41
- readonly opacity?: number;
42
- readonly x2?: number;
43
- readonly y2?: number;
44
- readonly stroke?: string;
45
- readonly strokeWidth?: number;
46
46
  }>;
47
47
  export {};
@@ -1,29 +1,34 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Schema from "effect/Schema";
3
- import * as Entity from "../Entity";
4
- import * as Shape2D from "./Shape2D";
3
+ import * as Color from "../Color.js";
4
+ import * as Entity from "../Entity.js";
5
+ import * as Shape2D from "./Shape2D.js";
5
6
  // No fill — a line is unfillable, so unlike the filled shapes it defaults
6
7
  // stroke white / strokeWidth 1: the visible default (see Shape2D.ts).
7
- // x/y is the start point, x2/y2 the end point.
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).
8
10
  const fields = {
9
11
  ...Shape2D.position,
10
12
  x2: Shape2D.defaultedNumber(0),
11
13
  y2: Shape2D.defaultedNumber(0),
12
- stroke: Schema.String.pipe(Schema.withConstructorDefault(Effect.succeed("white"))),
14
+ z2: Shape2D.defaultedNumber(0),
15
+ stroke: Color.Color.pipe(Schema.withConstructorDefault(Effect.succeed(Color.white))),
13
16
  strokeWidth: Shape2D.defaultedNumber(1),
14
17
  ...Shape2D.opacity,
15
18
  };
16
19
  export const Line = Entity.make("shapes/Line", fields, {
17
- // position moves the WHOLE line: translating x/y alone would stretch
20
+ // position moves the WHOLE line: translating x/y/z alone would stretch
18
21
  // it, so set shifts both endpoints by the delta (get = start point)
19
22
  "~position": {
20
- get: (data) => ({ x: data.x, y: data.y }),
23
+ get: (data) => ({ x: data.x, y: data.y, z: data.z }),
21
24
  set: (data, value) => ({
22
25
  ...data,
23
26
  x: value.x,
24
27
  y: value.y,
28
+ z: value.z,
25
29
  x2: data.x2 + (value.x - data.x),
26
30
  y2: data.y2 + (value.y - data.y),
31
+ z2: data.z2 + (value.z - data.z),
27
32
  }),
28
33
  },
29
34
  "~opacity": Shape2D.opacityLens(),
@@ -1,38 +1,107 @@
1
1
  import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity";
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;
3
17
  export declare const Path: Entity.Entity<"shapes/Path", Schema.Struct<{
4
18
  x: Schema.withConstructorDefault<Schema.Number>;
5
19
  y: Schema.withConstructorDefault<Schema.Number>;
20
+ z: Schema.withConstructorDefault<Schema.Number>;
6
21
  opacity: Schema.withConstructorDefault<Schema.Number>;
7
- fill: Schema.withConstructorDefault<Schema.String>;
8
- stroke: Schema.optionalKey<Schema.String>;
22
+ fill: Schema.withConstructorDefault<typeof import("../Color.js").Color>;
23
+ stroke: Schema.optionalKey<typeof import("../Color.js").Color>;
9
24
  strokeWidth: Schema.optionalKey<Schema.Number>;
10
- d: Schema.String;
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
+ }>>;
11
38
  }>, {
12
39
  readonly "~position": Entity.TraitLens<{
13
40
  readonly x: number;
14
41
  readonly y: number;
42
+ readonly z: number;
15
43
  readonly opacity: number;
16
- readonly fill: string;
17
- readonly stroke?: string;
44
+ readonly fill: import("../Color.js").Color;
45
+ readonly stroke?: import("../Color.js").Color;
18
46
  readonly strokeWidth?: number;
19
- readonly d: string;
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
+ })[]];
20
72
  }, Entity.Position>;
21
73
  readonly "~opacity": Entity.TraitLens<{
22
74
  readonly x: number;
23
75
  readonly y: number;
76
+ readonly z: number;
24
77
  readonly opacity: number;
25
- readonly fill: string;
26
- readonly stroke?: string;
78
+ readonly fill: import("../Color.js").Color;
79
+ readonly stroke?: import("../Color.js").Color;
27
80
  readonly strokeWidth?: number;
28
- readonly d: string;
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
+ })[]];
29
106
  }, number>;
30
- }, {
31
- readonly x?: number;
32
- readonly y?: number;
33
- readonly opacity?: number;
34
- readonly fill?: string;
35
- readonly stroke?: string;
36
- readonly strokeWidth?: number;
37
- readonly d: string;
38
107
  }>;
@@ -1,12 +1,31 @@
1
1
  import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity";
3
- import * as Shape2D from "./Shape2D";
4
- // `d` is required — an empty path can never be visible, so there is no
5
- // sensible default. x/y offset the whole path (targets translate it),
6
- // keeping position animatable without rewriting `d`.
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.
7
24
  export const Path = Entity.make("shapes/Path", {
8
25
  ...Shape2D.filled,
9
- d: Schema.String,
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" })),
10
29
  }, {
11
30
  "~position": Shape2D.positionLens(),
12
31
  "~opacity": Shape2D.opacityLens(),
@@ -1,41 +1,51 @@
1
- import * as Entity from "../Entity";
2
- export declare const Rect: Entity.Entity<"shapes/Rect", 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
- opacity: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
6
- fill: import("effect/Schema").withConstructorDefault<import("effect/Schema").String>;
7
- stroke: import("effect/Schema").optionalKey<import("effect/Schema").String>;
8
- strokeWidth: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
9
- width: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
10
- height: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
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>;
11
18
  }>, {
12
19
  readonly "~position": Entity.TraitLens<{
13
20
  readonly x: number;
14
21
  readonly y: number;
22
+ readonly z: number;
23
+ readonly rotX: number;
24
+ readonly rotY: number;
25
+ readonly rotZ: number;
15
26
  readonly opacity: number;
16
- readonly fill: string;
17
- readonly stroke?: string;
27
+ readonly fill: import("../Color.js").Color;
28
+ readonly stroke?: import("../Color.js").Color;
18
29
  readonly strokeWidth?: number;
19
30
  readonly width: number;
20
31
  readonly height: number;
32
+ readonly rx?: number;
33
+ readonly ry?: number;
21
34
  }, Entity.Position>;
22
35
  readonly "~opacity": Entity.TraitLens<{
23
36
  readonly x: number;
24
37
  readonly y: number;
38
+ readonly z: number;
39
+ readonly rotX: number;
40
+ readonly rotY: number;
41
+ readonly rotZ: number;
25
42
  readonly opacity: number;
26
- readonly fill: string;
27
- readonly stroke?: string;
43
+ readonly fill: import("../Color.js").Color;
44
+ readonly stroke?: import("../Color.js").Color;
28
45
  readonly strokeWidth?: number;
29
46
  readonly width: number;
30
47
  readonly height: number;
48
+ readonly rx?: number;
49
+ readonly ry?: number;
31
50
  }, number>;
32
- }, {
33
- readonly x?: number;
34
- readonly y?: number;
35
- readonly opacity?: number;
36
- readonly fill?: string;
37
- readonly stroke?: string;
38
- readonly strokeWidth?: number;
39
- readonly width?: number;
40
- readonly height?: number;
41
51
  }>;
@@ -1,9 +1,21 @@
1
- import * as Entity from "../Entity";
2
- import * as Shape2D from "./Shape2D";
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.
3
12
  export const Rect = Entity.make("shapes/Rect", {
4
13
  ...Shape2D.filled,
14
+ ...Shape2D.orientation,
5
15
  width: Shape2D.defaultedNumber(100),
6
16
  height: Shape2D.defaultedNumber(100),
17
+ rx: Schema.optionalKey(Schema.Number),
18
+ ry: Schema.optionalKey(Schema.Number),
7
19
  }, {
8
20
  "~position": Shape2D.positionLens(),
9
21
  "~opacity": Shape2D.opacityLens(),
@@ -1,5 +1,6 @@
1
1
  import * as Schema from "effect/Schema";
2
- import type * as Entity from "../Entity";
2
+ import * as Color from "../Color.js";
3
+ import type * as Entity from "../Entity.js";
3
4
  /**
4
5
  * The portable styling prop set shared by built-in shapes — deliberately
5
6
  * limited to what any plausible render target (SVG, canvas, Lottie) can
@@ -16,6 +17,12 @@ export declare const defaultedNumber: (value: number) => Schema.withConstructorD
16
17
  export declare const position: {
17
18
  x: Schema.withConstructorDefault<Schema.Number>;
18
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>;
19
26
  };
20
27
  export declare const opacity: {
21
28
  opacity: Schema.withConstructorDefault<Schema.Number>;
@@ -24,15 +31,17 @@ export declare const opacity: {
24
31
  export declare const filled: {
25
32
  x: Schema.withConstructorDefault<Schema.Number>;
26
33
  y: Schema.withConstructorDefault<Schema.Number>;
34
+ z: Schema.withConstructorDefault<Schema.Number>;
27
35
  opacity: Schema.withConstructorDefault<Schema.Number>;
28
- fill: Schema.withConstructorDefault<Schema.String>;
29
- stroke: Schema.optionalKey<Schema.String>;
36
+ fill: Schema.withConstructorDefault<typeof Color.Color>;
37
+ stroke: Schema.optionalKey<typeof Color.Color>;
30
38
  strokeWidth: Schema.optionalKey<Schema.Number>;
31
39
  };
32
- /** standard x/y position lens for shapes whose position IS x/y */
40
+ /** standard x/y/z position lens for shapes whose position IS x/y/z */
33
41
  export declare const positionLens: <Data extends {
34
42
  x: number;
35
43
  y: number;
44
+ z: number;
36
45
  }>() => Entity.TraitLens<Data, Entity.Position>;
37
46
  /** standard opacity lens */
38
47
  export declare const opacityLens: <Data extends {
@@ -1,5 +1,6 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Schema from "effect/Schema";
3
+ import * as Color from "../Color.js";
3
4
  /**
4
5
  * The portable styling prop set shared by built-in shapes — deliberately
5
6
  * limited to what any plausible render target (SVG, canvas, Lottie) can
@@ -13,9 +14,19 @@ import * as Schema from "effect/Schema";
13
14
  * emitted with placeholder values.
14
15
  */
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.
16
19
  export const position = {
17
20
  x: defaultedNumber(0),
18
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),
19
30
  };
20
31
  export const opacity = {
21
32
  opacity: defaultedNumber(1),
@@ -23,16 +34,16 @@ export const opacity = {
23
34
  /** Common fields for fillable shapes. */
24
35
  export const filled = {
25
36
  ...position,
26
- fill: Schema.String.pipe(Schema.withConstructorDefault(Effect.succeed("white"))),
27
- stroke: Schema.optionalKey(Schema.String),
37
+ fill: Color.Color.pipe(Schema.withConstructorDefault(Effect.succeed(Color.white))),
38
+ stroke: Schema.optionalKey(Color.Color),
28
39
  strokeWidth: Schema.optionalKey(Schema.Number),
29
40
  ...opacity,
30
41
  };
31
- /** standard x/y position lens for shapes whose position IS x/y */
42
+ /** standard x/y/z position lens for shapes whose position IS x/y/z */
32
43
  export const positionLens = () => ({
33
- get: (data) => ({ x: data.x, y: data.y }),
44
+ get: (data) => ({ x: data.x, y: data.y, z: data.z }),
34
45
  // spread of a generic yields Data & {...}; assignable back to Data
35
- set: (data, value) => ({ ...data, x: value.x, y: value.y }),
46
+ set: (data, value) => ({ ...data, x: value.x, y: value.y, z: value.z }),
36
47
  });
37
48
  /** standard opacity lens */
38
49
  export const opacityLens = () => ({
@@ -0,0 +1,11 @@
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";
@@ -0,0 +1,11 @@
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,37 +1,32 @@
1
- import * as Entity from "../Entity";
1
+ import * as Entity from "../Entity.js";
2
2
  export declare const Square: Entity.Entity<"shapes/Square", import("effect/Schema").Struct<{
3
3
  x: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
4
4
  y: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
5
+ z: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
5
6
  opacity: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
6
- fill: import("effect/Schema").withConstructorDefault<import("effect/Schema").String>;
7
- stroke: import("effect/Schema").optionalKey<import("effect/Schema").String>;
7
+ fill: import("effect/Schema").withConstructorDefault<typeof import("../Color.js").Color>;
8
+ stroke: import("effect/Schema").optionalKey<typeof import("../Color.js").Color>;
8
9
  strokeWidth: import("effect/Schema").optionalKey<import("effect/Schema").Number>;
9
10
  size: import("effect/Schema").withConstructorDefault<import("effect/Schema").Number>;
10
11
  }>, {
11
12
  readonly "~position": Entity.TraitLens<{
12
13
  readonly x: number;
13
14
  readonly y: number;
15
+ readonly z: number;
14
16
  readonly opacity: number;
15
- readonly fill: string;
16
- readonly stroke?: string;
17
+ readonly fill: import("../Color.js").Color;
18
+ readonly stroke?: import("../Color.js").Color;
17
19
  readonly strokeWidth?: number;
18
20
  readonly size: number;
19
21
  }, Entity.Position>;
20
22
  readonly "~opacity": Entity.TraitLens<{
21
23
  readonly x: number;
22
24
  readonly y: number;
25
+ readonly z: number;
23
26
  readonly opacity: number;
24
- readonly fill: string;
25
- readonly stroke?: string;
27
+ readonly fill: import("../Color.js").Color;
28
+ readonly stroke?: import("../Color.js").Color;
26
29
  readonly strokeWidth?: number;
27
30
  readonly size: number;
28
31
  }, number>;
29
- }, {
30
- readonly x?: number;
31
- readonly y?: number;
32
- readonly opacity?: number;
33
- readonly fill?: string;
34
- readonly stroke?: string;
35
- readonly strokeWidth?: number;
36
- readonly size?: number;
37
32
  }>;
@@ -1,5 +1,5 @@
1
- import * as Entity from "../Entity";
2
- import * as Shape2D from "./Shape2D";
1
+ import * as Entity from "../Entity.js";
2
+ import * as Shape2D from "./Shape2D.js";
3
3
  // its own entity, not Rect sugar: the schema IS the width === height
4
4
  // constraint, which a Rect can't enforce through updates
5
5
  export const Square = Entity.make("shapes/Square", {
@@ -1,5 +1,5 @@
1
1
  import * as Schema from "effect/Schema";
2
- import * as Entity from "../Entity";
2
+ import * as Entity from "../Entity.js";
3
3
  /**
4
4
  * A plain-string text leaf. `text` is required. The engine cannot measure
5
5
  * text, so alignment is delegated to SVG via `textAnchor` / `baseline`.
@@ -9,9 +9,10 @@ import * as Entity from "../Entity";
9
9
  export declare const Text: Entity.Entity<"shapes/Text", Schema.Struct<{
10
10
  x: Schema.withConstructorDefault<Schema.Number>;
11
11
  y: Schema.withConstructorDefault<Schema.Number>;
12
+ z: Schema.withConstructorDefault<Schema.Number>;
12
13
  opacity: Schema.withConstructorDefault<Schema.Number>;
13
- fill: Schema.withConstructorDefault<Schema.String>;
14
- stroke: Schema.optionalKey<Schema.String>;
14
+ fill: Schema.withConstructorDefault<typeof import("../Color.js").Color>;
15
+ stroke: Schema.optionalKey<typeof import("../Color.js").Color>;
15
16
  strokeWidth: Schema.optionalKey<Schema.Number>;
16
17
  text: Schema.String;
17
18
  fontSize: Schema.withConstructorDefault<Schema.Number>;
@@ -22,9 +23,10 @@ export declare const Text: Entity.Entity<"shapes/Text", Schema.Struct<{
22
23
  readonly "~position": Entity.TraitLens<{
23
24
  readonly x: number;
24
25
  readonly y: number;
26
+ readonly z: number;
25
27
  readonly opacity: number;
26
- readonly fill: string;
27
- readonly stroke?: string;
28
+ readonly fill: import("../Color.js").Color;
29
+ readonly stroke?: import("../Color.js").Color;
28
30
  readonly strokeWidth?: number;
29
31
  readonly text: string;
30
32
  readonly fontSize: number;
@@ -35,9 +37,10 @@ export declare const Text: Entity.Entity<"shapes/Text", Schema.Struct<{
35
37
  readonly "~opacity": Entity.TraitLens<{
36
38
  readonly x: number;
37
39
  readonly y: number;
40
+ readonly z: number;
38
41
  readonly opacity: number;
39
- readonly fill: string;
40
- readonly stroke?: string;
42
+ readonly fill: import("../Color.js").Color;
43
+ readonly stroke?: import("../Color.js").Color;
41
44
  readonly strokeWidth?: number;
42
45
  readonly text: string;
43
46
  readonly fontSize: number;
@@ -45,16 +48,4 @@ export declare const Text: Entity.Entity<"shapes/Text", Schema.Struct<{
45
48
  readonly textAnchor?: "end" | "middle" | "start";
46
49
  readonly baseline?: "auto" | "hanging" | "middle";
47
50
  }, number>;
48
- }, {
49
- readonly x?: number;
50
- readonly y?: number;
51
- readonly opacity?: number;
52
- readonly fill?: string;
53
- readonly stroke?: string;
54
- readonly strokeWidth?: number;
55
- readonly text: string;
56
- readonly fontSize?: number;
57
- readonly fontFamily?: string;
58
- readonly textAnchor?: "end" | "middle" | "start";
59
- readonly baseline?: "auto" | "hanging" | "middle";
60
51
  }>;
@@ -1,7 +1,7 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Schema from "effect/Schema";
3
- import * as Entity from "../Entity";
4
- import * as Shape2D from "./Shape2D";
3
+ import * as Entity from "../Entity.js";
4
+ import * as Shape2D from "./Shape2D.js";
5
5
  /**
6
6
  * A plain-string text leaf. `text` is required. The engine cannot measure
7
7
  * text, so alignment is delegated to SVG via `textAnchor` / `baseline`.