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
@@ -1,119 +0,0 @@
1
- import { Layer } from "effect";
2
- import * as Effect from "effect/Effect";
3
- import { ParticleField } from "../particles/ParticleField";
4
- import { particleField } from "../particles/render";
5
- import * as Shapes from "../shapes";
6
- import { entityRendererLayer } from "./layers";
7
- // absent props are omitted, never emitted with placeholders; opacity 1
8
- // (the SVG default) is omitted to keep output minimal
9
- const styleAttrs = (data) => {
10
- const attrs = {};
11
- if (data.fill !== undefined) {
12
- attrs.fill = data.fill;
13
- }
14
- if (data.stroke !== undefined) {
15
- attrs.stroke = data.stroke;
16
- }
17
- if (data.strokeWidth !== undefined) {
18
- attrs["stroke-width"] = data.strokeWidth;
19
- }
20
- if (data.opacity !== 1) {
21
- attrs.opacity = data.opacity;
22
- }
23
- return attrs;
24
- };
25
- export const circle = ({ data, }) => Effect.succeed({
26
- tag: "circle",
27
- props: { cx: data.x, cy: data.y, r: data.radius, ...styleAttrs(data) },
28
- });
29
- export const rect = ({ data, }) => Effect.succeed({
30
- tag: "rect",
31
- props: {
32
- x: data.x,
33
- y: data.y,
34
- width: data.width,
35
- height: data.height,
36
- ...styleAttrs(data),
37
- },
38
- });
39
- export const square = ({ data, }) => Effect.succeed({
40
- tag: "rect",
41
- props: {
42
- x: data.x,
43
- y: data.y,
44
- width: data.size,
45
- height: data.size,
46
- ...styleAttrs(data),
47
- },
48
- });
49
- export const ellipse = ({ data }) => Effect.succeed({
50
- tag: "ellipse",
51
- props: {
52
- cx: data.x,
53
- cy: data.y,
54
- rx: data.rx,
55
- ry: data.ry,
56
- ...styleAttrs(data),
57
- },
58
- });
59
- export const line = ({ data, }) => Effect.succeed({
60
- tag: "line",
61
- props: {
62
- x1: data.x,
63
- y1: data.y,
64
- x2: data.x2,
65
- y2: data.y2,
66
- ...styleAttrs(data),
67
- },
68
- });
69
- export const path = ({ data, }) => Effect.succeed({
70
- tag: "path",
71
- props: {
72
- d: data.d,
73
- // x/y offset the whole path; translate only when it does something
74
- ...(data.x !== 0 || data.y !== 0
75
- ? { transform: `translate(${data.x} ${data.y})` }
76
- : {}),
77
- ...styleAttrs(data),
78
- },
79
- });
80
- export const text = ({ data, }) => Effect.succeed({
81
- tag: "text",
82
- props: {
83
- x: data.x,
84
- y: data.y,
85
- "font-size": data.fontSize,
86
- "font-family": data.fontFamily,
87
- ...(data.textAnchor !== undefined
88
- ? { "text-anchor": data.textAnchor }
89
- : {}),
90
- ...(data.baseline !== undefined
91
- ? { "dominant-baseline": data.baseline }
92
- : {}),
93
- ...styleAttrs(data),
94
- },
95
- // plain string content; the string sink escapes it
96
- children: data.text,
97
- });
98
- // a group paints nothing itself: one <g> positioning its rendered children
99
- export const group = ({ data, children, }) => {
100
- const transform = Shapes.resolvedTransform(data);
101
- return Effect.succeed({
102
- tag: "g",
103
- props: {
104
- ...(Shapes.isIdentityTransform(transform)
105
- ? {}
106
- : {
107
- transform: `matrix(${transform.a} ${transform.b} ${transform.c} ${transform.d} ${transform.e} ${transform.f})`,
108
- }),
109
- ...styleAttrs(data),
110
- },
111
- children,
112
- });
113
- };
114
- // a parallax layer is a bare container: one <g> holding its children. It has
115
- // no position/opacity of its own; `depth` is consumed by the sink (svg/camera),
116
- // not emitted as an attribute here.
117
- export const layer = ({ children, }) => Effect.succeed({ tag: "g", props: {}, children });
118
- /** Every built-in shape registered with both sinks. */
119
- export const shapesLayer = Layer.mergeAll(entityRendererLayer(Shapes.Circle, circle), entityRendererLayer(Shapes.Rect, rect), entityRendererLayer(Shapes.Square, square), entityRendererLayer(Shapes.Ellipse, ellipse), entityRendererLayer(Shapes.Line, line), entityRendererLayer(Shapes.Path, path), entityRendererLayer(Shapes.Group, group), entityRendererLayer(Shapes.Layer, layer), entityRendererLayer(Shapes.Text, text), entityRendererLayer(ParticleField, particleField));