@motionscript/core 0.1.0-alpha.5 → 0.1.0-alpha.6
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.
- package/CHANGELOG.md +27 -0
- package/dist/browser/chunks/chunk-2RIYH36X.js +3 -0
- package/dist/browser/chunks/{chunk-QG6C23IJ.js.map → chunk-2RIYH36X.js.map} +4 -4
- package/dist/browser/chunks/chunk-DDJN3QII.js +15 -0
- package/dist/browser/chunks/chunk-DDJN3QII.js.map +7 -0
- package/dist/browser/chunks/chunk-DHB4COFY.js +2 -0
- package/dist/browser/chunks/chunk-DHB4COFY.js.map +7 -0
- package/dist/browser/chunks/chunk-EJDPYDQI.js +5 -0
- package/dist/browser/chunks/chunk-EJDPYDQI.js.map +7 -0
- package/dist/browser/chunks/chunk-XAWE4EAK.js +2 -0
- package/dist/browser/chunks/chunk-XAWE4EAK.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +4 -4
- package/dist/browser/experimental.js +2 -0
- package/dist/browser/experimental.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/jsx-jsx-dev-runtime.js +1 -1
- package/dist/browser/jsx-jsx-runtime.js +1 -1
- package/dist/browser/manifest.json +2 -1
- package/dist/browser/sdk.js +1 -1
- package/dist/component/api.d.ts +508 -0
- package/dist/component/api.d.ts.map +1 -0
- package/dist/component/api.js +4 -0
- package/dist/component/api.js.map +1 -0
- package/dist/component/builtins/audio.d.ts +26 -0
- package/dist/component/builtins/audio.d.ts.map +1 -0
- package/dist/component/builtins/audio.js +41 -0
- package/dist/component/builtins/audio.js.map +1 -0
- package/dist/component/builtins/canvas3d.d.ts +98 -0
- package/dist/component/builtins/canvas3d.d.ts.map +1 -0
- package/dist/component/builtins/canvas3d.js +21 -0
- package/dist/component/builtins/canvas3d.js.map +1 -0
- package/dist/component/builtins/composite.d.ts +56 -0
- package/dist/component/builtins/composite.d.ts.map +1 -0
- package/dist/component/builtins/composite.js +25 -0
- package/dist/component/builtins/composite.js.map +1 -0
- package/dist/component/builtins/geometry.d.ts +505 -0
- package/dist/component/builtins/geometry.d.ts.map +1 -0
- package/dist/component/builtins/geometry.js +107 -0
- package/dist/component/builtins/geometry.js.map +1 -0
- package/dist/component/builtins/layout.d.ts +88 -0
- package/dist/component/builtins/layout.d.ts.map +1 -0
- package/dist/component/builtins/layout.js +84 -0
- package/dist/component/builtins/layout.js.map +1 -0
- package/dist/component/builtins/media.d.ts +95 -0
- package/dist/component/builtins/media.d.ts.map +1 -0
- package/dist/component/builtins/media.js +149 -0
- package/dist/component/builtins/media.js.map +1 -0
- package/dist/component/builtins/providers.d.ts +23 -0
- package/dist/component/builtins/providers.d.ts.map +1 -0
- package/dist/component/builtins/providers.js +30 -0
- package/dist/component/builtins/providers.js.map +1 -0
- package/dist/component/builtins/text.d.ts +193 -0
- package/dist/component/builtins/text.d.ts.map +1 -0
- package/dist/component/builtins/text.js +113 -0
- package/dist/component/builtins/text.js.map +1 -0
- package/dist/component/builtins/three.d.ts +1085 -0
- package/dist/component/builtins/three.d.ts.map +1 -0
- package/dist/component/builtins/three.js +265 -0
- package/dist/component/builtins/three.js.map +1 -0
- package/dist/component/clip-of.d.ts +5 -0
- package/dist/component/clip-of.d.ts.map +1 -0
- package/dist/component/clip-of.js +33 -0
- package/dist/component/clip-of.js.map +1 -0
- package/dist/component/commands-for.d.ts +19 -0
- package/dist/component/commands-for.d.ts.map +1 -0
- package/dist/component/commands-for.js +5 -0
- package/dist/component/commands-for.js.map +1 -0
- package/dist/component/component-audio.d.ts +9 -0
- package/dist/component/component-audio.d.ts.map +1 -0
- package/dist/component/component-audio.js +18 -0
- package/dist/component/component-audio.js.map +1 -0
- package/dist/component/component2d.d.ts +9 -0
- package/dist/component/component2d.d.ts.map +1 -0
- package/dist/component/component2d.js +239 -0
- package/dist/component/component2d.js.map +1 -0
- package/dist/component/component3d.d.ts +9 -0
- package/dist/component/component3d.d.ts.map +1 -0
- package/dist/component/component3d.js +99 -0
- package/dist/component/component3d.js.map +1 -0
- package/dist/component/factory.d.ts +63 -0
- package/dist/component/factory.d.ts.map +1 -0
- package/dist/component/factory.js +313 -0
- package/dist/component/factory.js.map +1 -0
- package/dist/component/modules/aim.d.ts +30 -0
- package/dist/component/modules/aim.d.ts.map +1 -0
- package/dist/component/modules/aim.js +39 -0
- package/dist/component/modules/aim.js.map +1 -0
- package/dist/component/modules/corners.d.ts +13 -0
- package/dist/component/modules/corners.d.ts.map +1 -0
- package/dist/component/modules/corners.js +12 -0
- package/dist/component/modules/corners.js.map +1 -0
- package/dist/component/modules/flow.d.ts +26 -0
- package/dist/component/modules/flow.d.ts.map +1 -0
- package/dist/component/modules/flow.js +55 -0
- package/dist/component/modules/flow.js.map +1 -0
- package/dist/component/modules/material.d.ts +40 -0
- package/dist/component/modules/material.d.ts.map +1 -0
- package/dist/component/modules/material.js +75 -0
- package/dist/component/modules/material.js.map +1 -0
- package/dist/component/modules/paint.d.ts +71 -0
- package/dist/component/modules/paint.d.ts.map +1 -0
- package/dist/component/modules/paint.js +106 -0
- package/dist/component/modules/paint.js.map +1 -0
- package/dist/component/modules/shapes.d.ts +31 -0
- package/dist/component/modules/shapes.d.ts.map +1 -0
- package/dist/component/modules/shapes.js +43 -0
- package/dist/component/modules/shapes.js.map +1 -0
- package/dist/component/modules/text-layout.d.ts +26 -0
- package/dist/component/modules/text-layout.d.ts.map +1 -0
- package/dist/component/modules/text-layout.js +57 -0
- package/dist/component/modules/text-layout.js.map +1 -0
- package/dist/component/modules/text-style.d.ts +48 -0
- package/dist/component/modules/text-style.d.ts.map +1 -0
- package/dist/component/modules/text-style.js +63 -0
- package/dist/component/modules/text-style.js.map +1 -0
- package/dist/component/modules/three-entries.d.ts +23 -0
- package/dist/component/modules/three-entries.d.ts.map +1 -0
- package/dist/component/modules/three-entries.js +41 -0
- package/dist/component/modules/three-entries.js.map +1 -0
- package/dist/component/modules/view3d.d.ts +55 -0
- package/dist/component/modules/view3d.d.ts.map +1 -0
- package/dist/component/modules/view3d.js +160 -0
- package/dist/component/modules/view3d.js.map +1 -0
- package/dist/component/timeline.d.ts +22 -0
- package/dist/component/timeline.d.ts.map +1 -0
- package/dist/component/timeline.js +128 -0
- package/dist/component/timeline.js.map +1 -0
- package/dist/component/type-def.d.ts +26 -0
- package/dist/component/type-def.d.ts.map +1 -0
- package/dist/component/type-def.js +16 -0
- package/dist/component/type-def.js.map +1 -0
- package/dist/component/types.d.ts +91 -0
- package/dist/component/types.d.ts.map +1 -0
- package/dist/component/types.js +88 -0
- package/dist/component/types.js.map +1 -0
- package/dist/component/views.d.ts +121 -0
- package/dist/component/views.d.ts.map +1 -0
- package/dist/component/views.js +413 -0
- package/dist/component/views.js.map +1 -0
- package/dist/component.d.ts +4 -5
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +3 -5
- package/dist/component.js.map +1 -1
- package/dist/document/audio.d.ts +9 -1
- package/dist/document/audio.d.ts.map +1 -1
- package/dist/document/audio.js +41 -0
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +9 -27
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.js +3 -0
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/diff.d.ts.map +1 -1
- package/dist/document/diff.js +3 -3
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js +3 -3
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +6 -0
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.js +2 -2
- package/dist/document/placement.js.map +1 -1
- package/dist/document/registry.d.ts +6 -11
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +17 -17
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +49 -0
- package/dist/document/settled-index.d.ts.map +1 -0
- package/dist/document/settled-index.js +247 -0
- package/dist/document/settled-index.js.map +1 -0
- package/dist/document/timeline.d.ts +27 -1
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +98 -2
- package/dist/document/timeline.js.map +1 -1
- package/dist/experimental.d.ts +22 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +20 -0
- package/dist/experimental.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/nodes/audio/index.d.ts +2 -2
- package/dist/nodes/audio/index.d.ts.map +1 -1
- package/dist/nodes/audio/index.js +0 -2
- package/dist/nodes/audio/index.js.map +1 -1
- package/dist/nodes/audio/sound-node.d.ts +2 -1
- package/dist/nodes/audio/sound-node.d.ts.map +1 -1
- package/dist/nodes/audio/sound-node.js +3 -0
- package/dist/nodes/audio/sound-node.js.map +1 -1
- package/dist/nodes/index.d.ts +39 -27
- package/dist/nodes/index.d.ts.map +1 -1
- package/dist/nodes/index.js +16 -30
- package/dist/nodes/index.js.map +1 -1
- package/dist/nodes/node/node.d.ts +7 -1
- package/dist/nodes/node/node.d.ts.map +1 -1
- package/dist/nodes/node/node.js +23 -8
- package/dist/nodes/node/node.js.map +1 -1
- package/dist/nodes/root/canvas2d-node.d.ts +2 -1
- package/dist/nodes/root/canvas2d-node.d.ts.map +1 -1
- package/dist/nodes/root/canvas2d-node.js +3 -0
- package/dist/nodes/root/canvas2d-node.js.map +1 -1
- package/dist/nodes/text/richtext-node.d.ts +0 -5
- package/dist/nodes/text/richtext-node.d.ts.map +1 -1
- package/dist/nodes/text/richtext-node.js +5 -71
- package/dist/nodes/text/richtext-node.js.map +1 -1
- package/dist/nodes/text/text-base.d.ts +5 -22
- package/dist/nodes/text/text-base.d.ts.map +1 -1
- package/dist/nodes/text/text-base.js +12 -363
- package/dist/nodes/text/text-base.js.map +1 -1
- package/dist/nodes/text/text-layout.d.ts +87 -0
- package/dist/nodes/text/text-layout.d.ts.map +1 -0
- package/dist/nodes/text/text-layout.js +368 -0
- package/dist/nodes/text/text-layout.js.map +1 -0
- package/dist/nodes/three/canvas3d-node.d.ts +3 -1
- package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
- package/dist/nodes/three/canvas3d-node.js +6 -0
- package/dist/nodes/three/canvas3d-node.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +4 -1
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +17 -3
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +9 -0
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +78 -0
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +6 -7
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +11 -4
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +5 -0
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts.map +1 -1
- package/dist/runtime/text-geometry.js +7 -3
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +35 -14
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +47 -42
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command.d.ts +12 -0
- package/dist/tween/command.d.ts.map +1 -1
- package/dist/tween/command.js +14 -0
- package/dist/tween/command.js.map +1 -1
- package/package.json +6 -1
- package/dist/browser/chunks/chunk-FUZVFT3W.js +0 -18
- package/dist/browser/chunks/chunk-FUZVFT3W.js.map +0 -7
- package/dist/browser/chunks/chunk-QG6C23IJ.js +0 -3
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { lerpCornerScalarStyle } from "../../attributes/shape/corners/corner-style.js";
|
|
2
|
+
import { pathOps } from "../../attributes/shape/path/ops.js";
|
|
3
|
+
import { STAR_DEFAULT_POINTS, STAR_DEFAULT_RATIO } from "../../nodes/geometry/shape-outline.js";
|
|
4
|
+
import { component2d } from "../../component/component2d.js";
|
|
5
|
+
import { Types } from "../../component/types.js";
|
|
6
|
+
import * as Corners from "../../component/modules/corners.js";
|
|
7
|
+
import * as Flow from "../../component/modules/flow.js";
|
|
8
|
+
import * as Paint from "../../component/modules/paint.js";
|
|
9
|
+
import * as Shapes from "../../component/modules/shapes.js";
|
|
10
|
+
/**
|
|
11
|
+
* The geometry built-ins: paint, the flow engine for children (clear of the
|
|
12
|
+
* stroke), and each one's outline.
|
|
13
|
+
*/
|
|
14
|
+
const scalarCorners = {
|
|
15
|
+
cornerRadius: Types.number(0),
|
|
16
|
+
cornerStyle: Types.custom("rounded", { lerp: lerpCornerScalarStyle }),
|
|
17
|
+
};
|
|
18
|
+
export const Rect = component2d({
|
|
19
|
+
key: "rect",
|
|
20
|
+
state: { ...Paint.state, ...Flow.state, ...Corners.state },
|
|
21
|
+
commands: { ...Paint.commands },
|
|
22
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
23
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
24
|
+
render: (ctx, state) => Paint.draw(ctx, state, Corners.rect(ctx.size, state)),
|
|
25
|
+
});
|
|
26
|
+
export const Ellipse = component2d({
|
|
27
|
+
key: "ellipse",
|
|
28
|
+
state: {
|
|
29
|
+
...Paint.state, ...Flow.state,
|
|
30
|
+
startAngle: Types.number(0),
|
|
31
|
+
sweep: Types.number(360),
|
|
32
|
+
ratio: Types.number(0),
|
|
33
|
+
},
|
|
34
|
+
commands: { ...Paint.commands },
|
|
35
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
36
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
37
|
+
render: (ctx, state) => Paint.draw(ctx, state, Shapes.ellipse(ctx.size, state)),
|
|
38
|
+
});
|
|
39
|
+
export const Polygon = component2d({
|
|
40
|
+
key: "polygon",
|
|
41
|
+
state: { ...Paint.state, ...Flow.state, sides: Types.number(5), ...scalarCorners },
|
|
42
|
+
commands: { ...Paint.commands },
|
|
43
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
44
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
45
|
+
render: (ctx, state) => Paint.draw(ctx, state, Shapes.polygon(ctx.size, state)),
|
|
46
|
+
});
|
|
47
|
+
export const Polygram = component2d({
|
|
48
|
+
key: "polygram",
|
|
49
|
+
state: { ...Paint.state, ...Flow.state, sides: Types.number(5), ratio: Types.number(0.5), ...scalarCorners },
|
|
50
|
+
commands: { ...Paint.commands },
|
|
51
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
52
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
53
|
+
render: (ctx, state) => Paint.draw(ctx, state, Shapes.polygram(ctx.size, state)),
|
|
54
|
+
});
|
|
55
|
+
/** The document's `path`: `data` in the unit space of its own box, so a resize is a width/height write. */
|
|
56
|
+
export const PathShape = component2d({
|
|
57
|
+
key: "path",
|
|
58
|
+
state: { ...Paint.state, ...Flow.state, data: Types.path },
|
|
59
|
+
commands: { ...Paint.commands },
|
|
60
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
61
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
62
|
+
render: (ctx, state) => Paint.draw(ctx, state, Shapes.unitPath(ctx.size, state.data), { clipShape: Shapes.box(ctx.size) }),
|
|
63
|
+
});
|
|
64
|
+
/** Path data drawn at face value, hugging it: geometry written in code. */
|
|
65
|
+
export const Path = component2d({
|
|
66
|
+
key: "facePath",
|
|
67
|
+
state: { ...Paint.state, ...Flow.state, data: Types.path },
|
|
68
|
+
defaults: { width: "hug", height: "hug" },
|
|
69
|
+
commands: { ...Paint.commands },
|
|
70
|
+
measure: (_measurer, state) => {
|
|
71
|
+
const intrinsic = pathOps.size(state.data);
|
|
72
|
+
const pad = state.padding;
|
|
73
|
+
return { width: intrinsic.width + pad.left + pad.right, height: intrinsic.height + pad.top + pad.bottom };
|
|
74
|
+
},
|
|
75
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
76
|
+
render: (ctx, state) => Paint.draw(ctx, state, Shapes.facePath(state.data), { clipShape: null }),
|
|
77
|
+
});
|
|
78
|
+
function boundsShape(key, kind) {
|
|
79
|
+
return component2d({
|
|
80
|
+
key,
|
|
81
|
+
state: { ...Paint.state, ...Flow.state, ...scalarCorners },
|
|
82
|
+
commands: { ...Paint.commands },
|
|
83
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
84
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
85
|
+
render: (ctx, state) => Paint.draw(ctx, state, Shapes.outline(kind, ctx.size, state), { clipShape: Shapes.box(ctx.size) }),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
export const Triangle = boundsShape("triangle", "triangle");
|
|
89
|
+
export const RightTriangle = boundsShape("rightTriangle", "rightTriangle");
|
|
90
|
+
export const Pentagon = boundsShape("pentagon", "pentagon");
|
|
91
|
+
export const Hexagon = boundsShape("hexagon", "hexagon");
|
|
92
|
+
export const Octagon = boundsShape("octagon", "octagon");
|
|
93
|
+
export const Star = component2d({
|
|
94
|
+
key: "star",
|
|
95
|
+
state: {
|
|
96
|
+
...Paint.state, ...Flow.state, ...scalarCorners,
|
|
97
|
+
points: Types.number(STAR_DEFAULT_POINTS),
|
|
98
|
+
ratio: Types.number(STAR_DEFAULT_RATIO),
|
|
99
|
+
},
|
|
100
|
+
commands: { ...Paint.commands },
|
|
101
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
102
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
103
|
+
render: (ctx, state) => Paint.draw(ctx, state, Shapes.outline("star", ctx.size, {
|
|
104
|
+
cornerRadius: state.cornerRadius, cornerStyle: state.cornerStyle, sides: Math.max(3, Math.round(state.points)), ratio: state.ratio,
|
|
105
|
+
}), { clipShape: Shapes.box(ctx.size) }),
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../../src/component/builtins/geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAoB,MAAM,yCAAyC,CAAC;AAClG,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAyB,MAAM,gCAAgC,CAAC;AAEhH,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,KAAK,IAAI,MAAM,0BAA0B,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAC;AAErD;;;GAGG;AAEH,MAAM,aAAa,GAAG;IAClB,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAc,SAAS,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC;CACrF,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAC;IAC5B,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,K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EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE;QAC5E,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK;KACrI,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;CAC3C,CAAC,CAAC","sourcesContent":["import { lerpCornerScalarStyle, type CornerStyle } from \"@/attributes/shape/corners/corner-style\";\r\nimport { pathOps } from \"@/attributes/shape/path/ops\";\r\nimport { STAR_DEFAULT_POINTS, STAR_DEFAULT_RATIO, type ShapeOutlineKind } from \"@/nodes/geometry/shape-outline\";\r\nimport type { NodeOf } from \"@/component/api\";\r\nimport { component2d } from \"@/component/component2d\";\r\nimport { Types } from \"@/component/types\";\r\nimport * as Corners from \"@/component/modules/corners\";\r\nimport * as Flow from \"@/component/modules/flow\";\r\nimport * as Paint from \"@/component/modules/paint\";\r\nimport * as Shapes from \"@/component/modules/shapes\";\r\n\r\n/**\r\n * The geometry built-ins: paint, the flow engine for children (clear of the\r\n * stroke), and each one's outline.\r\n */\r\n\r\nconst scalarCorners = {\r\n cornerRadius: Types.number(0),\r\n cornerStyle: Types.custom<CornerStyle>(\"rounded\", { lerp: lerpCornerScalarStyle }),\r\n};\r\n\r\nexport const Rect = component2d({\r\n key: \"rect\",\r\n state: { ...Paint.state, ...Flow.state, ...Corners.state },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Corners.rect(ctx.size, state)),\r\n});\r\n\r\nexport const Ellipse = component2d({\r\n key: \"ellipse\",\r\n state: {\r\n ...Paint.state, ...Flow.state,\r\n startAngle: Types.number(0),\r\n sweep: Types.number(360),\r\n ratio: Types.number(0),\r\n },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.ellipse(ctx.size, state)),\r\n});\r\n\r\nexport const Polygon = component2d({\r\n key: \"polygon\",\r\n state: { ...Paint.state, ...Flow.state, sides: Types.number(5), ...scalarCorners },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.polygon(ctx.size, state)),\r\n});\r\n\r\nexport const Polygram = component2d({\r\n key: \"polygram\",\r\n state: { ...Paint.state, ...Flow.state, sides: Types.number(5), ratio: Types.number(0.5), ...scalarCorners },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.polygram(ctx.size, state)),\r\n});\r\n\r\n/** The document's `path`: `data` in the unit space of its own box, so a resize is a width/height write. */\r\nexport const PathShape = component2d({\r\n key: \"path\",\r\n state: { ...Paint.state, ...Flow.state, data: Types.path },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.unitPath(ctx.size, state.data), { clipShape: Shapes.box(ctx.size) }),\r\n});\r\n\r\n/** Path data drawn at face value, hugging it: geometry written in code. */\r\nexport const Path = component2d({\r\n key: \"facePath\",\r\n state: { ...Paint.state, ...Flow.state, data: Types.path },\r\n defaults: { width: \"hug\", height: \"hug\" },\r\n commands: { ...Paint.commands },\r\n measure: (_measurer, state) => {\r\n const intrinsic = pathOps.size(state.data);\r\n const pad = state.padding;\r\n return { width: intrinsic.width + pad.left + pad.right, height: intrinsic.height + pad.top + pad.bottom };\r\n },\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.facePath(state.data), { clipShape: null }),\r\n});\r\n\r\nfunction boundsShape<const K extends string>(key: K, kind: ShapeOutlineKind) {\r\n return component2d({\r\n key,\r\n state: { ...Paint.state, ...Flow.state, ...scalarCorners },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.outline(kind, ctx.size, state), { clipShape: Shapes.box(ctx.size) }),\r\n });\r\n}\r\n\r\nexport const Triangle = boundsShape(\"triangle\", \"triangle\");\r\nexport const RightTriangle = boundsShape(\"rightTriangle\", \"rightTriangle\");\r\nexport const Pentagon = boundsShape(\"pentagon\", \"pentagon\");\r\nexport const Hexagon = boundsShape(\"hexagon\", \"hexagon\");\r\nexport const Octagon = boundsShape(\"octagon\", \"octagon\");\r\n\r\nexport const Star = component2d({\r\n key: \"star\",\r\n state: {\r\n ...Paint.state, ...Flow.state, ...scalarCorners,\r\n points: Types.number(STAR_DEFAULT_POINTS),\r\n ratio: Types.number(STAR_DEFAULT_RATIO),\r\n },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.outline(\"star\", ctx.size, {\r\n cornerRadius: state.cornerRadius, cornerStyle: state.cornerStyle, sides: Math.max(3, Math.round(state.points)), ratio: state.ratio,\r\n }), { clipShape: Shapes.box(ctx.size) }),\r\n});\r\n\r\nexport type Rect = NodeOf<typeof Rect>;\r\nexport type Ellipse = NodeOf<typeof Ellipse>;\r\nexport type Polygon = NodeOf<typeof Polygon>;\r\nexport type Polygram = NodeOf<typeof Polygram>;\r\nexport type PathShape = NodeOf<typeof PathShape>;\r\nexport type Path = NodeOf<typeof Path>;\r\nexport type Triangle = NodeOf<typeof Triangle>;\r\nexport type RightTriangle = NodeOf<typeof RightTriangle>;\r\nexport type Pentagon = NodeOf<typeof Pentagon>;\r\nexport type Hexagon = NodeOf<typeof Hexagon>;\r\nexport type Octagon = NodeOf<typeof Octagon>;\r\nexport type Star = NodeOf<typeof Star>;\r\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type LookAt } from "../../attributes/layout/space3d.js";
|
|
2
|
+
import type { NodeOf } from "../../component/api.js";
|
|
3
|
+
/** A framed viewport: painted like a rect, its children seen through a camera aimed inside it. */
|
|
4
|
+
export declare const Camera: import("../../component/api.js").Component<"camera", import("../../component/api.js").Merge<import("../../component/api.js").Box2DState, {
|
|
5
|
+
readonly cornerRadius: import("../../component/types.js").Attribute<import("../../index.js").RectCornerRadius, import("../../index.js").CornerRadiusResolved>;
|
|
6
|
+
readonly cornerStyle: import("../../component/types.js").Attribute<import("../../index.js").RectCornerStyle, import("../../index.js").CornerStyleResolved>;
|
|
7
|
+
readonly zoom: import("../../component/api.js").Type<number, number, false>;
|
|
8
|
+
readonly lookAt: import("../../component/api.js").Type<import("../../index.js").Vector2, import("../../index.js").Vector2, false>;
|
|
9
|
+
readonly heading: import("../../component/api.js").Type<number, number, false>;
|
|
10
|
+
readonly follow: import("../../component/api.js").Type<string, import("../../component/api.js").NodeView<import("../../component/api.js").Element<string, unknown, unknown>> | null, false>;
|
|
11
|
+
readonly flow: import("../../component/api.js").Type<import("../../index.js").FlowMode, import("../../index.js").FlowResolved, false>;
|
|
12
|
+
readonly gap: import("../../component/api.js").Type<import("../../index.js").GapSize, import("../../index.js").GapSize, false>;
|
|
13
|
+
readonly wrap: boolean;
|
|
14
|
+
readonly crossGap: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
15
|
+
readonly columns: import("../../component/api.js").Type<number, number, false>;
|
|
16
|
+
readonly align: import("../../component/types.js").Attribute<import("../../index.js").Alignment, import("../../index.js").Vector2>;
|
|
17
|
+
readonly fill: import("../../component/types.js").Attribute<import("../../index.js").Fill, import("../../index.js").FillResolved[]>;
|
|
18
|
+
readonly stroke: import("../../component/types.js").Attribute<import("../../index.js").Stroke, import("../../index.js").StrokeResolved[]>;
|
|
19
|
+
readonly shadow: import("../../component/types.js").Attribute<import("../../index.js").Shadow, import("../../index.js").ShadowResolved[]>;
|
|
20
|
+
readonly overlay: import("../../component/types.js").Attribute<import("../../index.js").Fill, import("../../index.js").FillResolved[]>;
|
|
21
|
+
readonly start: import("../../component/api.js").Type<number, number, false>;
|
|
22
|
+
readonly end: import("../../component/api.js").Type<number, number, false>;
|
|
23
|
+
}>, {
|
|
24
|
+
readonly zoomTo: readonly ["zoom"];
|
|
25
|
+
readonly panTo: readonly ["lookAt"];
|
|
26
|
+
readonly headingTo: readonly ["heading"];
|
|
27
|
+
readonly fillTo: readonly ["fill"];
|
|
28
|
+
readonly strokeTo: readonly ["stroke"];
|
|
29
|
+
readonly shadowTo: readonly ["shadow"];
|
|
30
|
+
readonly overlayTo: readonly ["overlay"];
|
|
31
|
+
readonly progressTo: readonly ["start", "end"];
|
|
32
|
+
readonly flash: {
|
|
33
|
+
readonly portion: import("../../component/api.js").Type<number, number, false>;
|
|
34
|
+
};
|
|
35
|
+
}, null, import("../../index.js").Node2D<import("../../index.js").Node2DProps>, import("../../component/api.js").CallProps<import("../../component/api.js").Merge<import("../../component/api.js").Box2DState, {
|
|
36
|
+
readonly cornerRadius: import("../../component/types.js").Attribute<import("../../index.js").RectCornerRadius, import("../../index.js").CornerRadiusResolved>;
|
|
37
|
+
readonly cornerStyle: import("../../component/types.js").Attribute<import("../../index.js").RectCornerStyle, import("../../index.js").CornerStyleResolved>;
|
|
38
|
+
readonly zoom: import("../../component/api.js").Type<number, number, false>;
|
|
39
|
+
readonly lookAt: import("../../component/api.js").Type<import("../../index.js").Vector2, import("../../index.js").Vector2, false>;
|
|
40
|
+
readonly heading: import("../../component/api.js").Type<number, number, false>;
|
|
41
|
+
readonly follow: import("../../component/api.js").Type<string, import("../../component/api.js").NodeView<import("../../component/api.js").Element<string, unknown, unknown>> | null, false>;
|
|
42
|
+
readonly flow: import("../../component/api.js").Type<import("../../index.js").FlowMode, import("../../index.js").FlowResolved, false>;
|
|
43
|
+
readonly gap: import("../../component/api.js").Type<import("../../index.js").GapSize, import("../../index.js").GapSize, false>;
|
|
44
|
+
readonly wrap: boolean;
|
|
45
|
+
readonly crossGap: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
46
|
+
readonly columns: import("../../component/api.js").Type<number, number, false>;
|
|
47
|
+
readonly align: import("../../component/types.js").Attribute<import("../../index.js").Alignment, import("../../index.js").Vector2>;
|
|
48
|
+
readonly fill: import("../../component/types.js").Attribute<import("../../index.js").Fill, import("../../index.js").FillResolved[]>;
|
|
49
|
+
readonly stroke: import("../../component/types.js").Attribute<import("../../index.js").Stroke, import("../../index.js").StrokeResolved[]>;
|
|
50
|
+
readonly shadow: import("../../component/types.js").Attribute<import("../../index.js").Shadow, import("../../index.js").ShadowResolved[]>;
|
|
51
|
+
readonly overlay: import("../../component/types.js").Attribute<import("../../index.js").Fill, import("../../index.js").FillResolved[]>;
|
|
52
|
+
readonly start: import("../../component/api.js").Type<number, number, false>;
|
|
53
|
+
readonly end: import("../../component/api.js").Type<number, number, false>;
|
|
54
|
+
}>, null>>;
|
|
55
|
+
/** The stage's 2.5D camera for one subtree: its children stand in one space, orbited in depth. */
|
|
56
|
+
export declare const OrbitCamera: import("../../component/api.js").Component<"orbitCamera", import("../../component/api.js").Merge<import("../../component/api.js").Box2DState, {
|
|
57
|
+
lookAt: import("../../component/api.js").Type<LookAt, LookAt, false>;
|
|
58
|
+
zoom: import("../../component/api.js").Type<number, number, false>;
|
|
59
|
+
heading: import("../../component/api.js").Type<number, number, false>;
|
|
60
|
+
orbit: import("../../component/api.js").Type<number, number, false>;
|
|
61
|
+
elevation: import("../../component/api.js").Type<number, number, false>;
|
|
62
|
+
dolly: import("../../component/api.js").Type<number, number, false>;
|
|
63
|
+
orbitSpeed: import("../../component/api.js").Type<number, number, false>;
|
|
64
|
+
}>, {
|
|
65
|
+
readonly orbitTo: readonly ["orbit", "elevation"];
|
|
66
|
+
readonly dollyTo: readonly ["dolly"];
|
|
67
|
+
readonly zoomTo: readonly ["zoom"];
|
|
68
|
+
readonly panTo: readonly ["lookAt"];
|
|
69
|
+
readonly headingTo: readonly ["heading"];
|
|
70
|
+
}, null, import("../../index.js").Node2D<import("../../index.js").Node2DProps>, import("../../component/api.js").CallProps<import("../../component/api.js").Merge<import("../../component/api.js").Box2DState, {
|
|
71
|
+
lookAt: import("../../component/api.js").Type<LookAt, LookAt, false>;
|
|
72
|
+
zoom: import("../../component/api.js").Type<number, number, false>;
|
|
73
|
+
heading: import("../../component/api.js").Type<number, number, false>;
|
|
74
|
+
orbit: import("../../component/api.js").Type<number, number, false>;
|
|
75
|
+
elevation: import("../../component/api.js").Type<number, number, false>;
|
|
76
|
+
dolly: import("../../component/api.js").Type<number, number, false>;
|
|
77
|
+
orbitSpeed: import("../../component/api.js").Type<number, number, false>;
|
|
78
|
+
}>, null>>;
|
|
79
|
+
/** Its children laid out in a box turned by `angle`, and turned with it: the box it reports is the turned one's bounds. */
|
|
80
|
+
export declare const RotatedBox: import("../../component/api.js").Component<"rotated-box", import("../../component/api.js").Merge<import("../../component/api.js").Box2DState, {
|
|
81
|
+
readonly angle: import("../../component/api.js").Type<number, number, false>;
|
|
82
|
+
}>, {}, null, import("../../index.js").Node2D<import("../../index.js").Node2DProps>, import("../../component/api.js").CallProps<import("../../component/api.js").Merge<import("../../component/api.js").Box2DState, {
|
|
83
|
+
readonly angle: import("../../component/api.js").Type<number, number, false>;
|
|
84
|
+
}>, null>>;
|
|
85
|
+
export type Camera = NodeOf<typeof Camera>;
|
|
86
|
+
export type OrbitCamera = NodeOf<typeof OrbitCamera>;
|
|
87
|
+
export type RotatedBox = NodeOf<typeof RotatedBox>;
|
|
88
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/component/builtins/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAS9C,kGAAkG;AAClG,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAOjB,CAAC;AAcH,kGAAkG;AAClG,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;UAsBtB,CAAC;AAEH,2HAA2H;AAC3H,eAAO,MAAM,UAAU;;;;UAyBrB,CAAC;AAOH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC;AAC3C,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AACrD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { lerpLookAt } from "../../attributes/layout/space3d.js";
|
|
2
|
+
import { component2d } from "../../component/component2d.js";
|
|
3
|
+
import { commandsFor } from "../../component/commands-for.js";
|
|
4
|
+
import { Types } from "../../component/types.js";
|
|
5
|
+
import * as Aim from "../../component/modules/aim.js";
|
|
6
|
+
import * as Corners from "../../component/modules/corners.js";
|
|
7
|
+
import * as Flow from "../../component/modules/flow.js";
|
|
8
|
+
import * as Paint from "../../component/modules/paint.js";
|
|
9
|
+
/** A framed viewport: painted like a rect, its children seen through a camera aimed inside it. */
|
|
10
|
+
export const Camera = component2d({
|
|
11
|
+
key: "camera",
|
|
12
|
+
state: { ...Paint.state, ...Flow.state, ...Aim.state, ...Corners.state },
|
|
13
|
+
commands: { ...Paint.commands, ...Aim.commands },
|
|
14
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
15
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
16
|
+
render: (ctx, state) => Paint.draw(ctx, state, Corners.rect(ctx.size, state), { children: () => Aim.camera(ctx, state) }),
|
|
17
|
+
});
|
|
18
|
+
const orbit = {
|
|
19
|
+
lookAt: Types.custom({ x: 0, y: 0 }, {
|
|
20
|
+
lerp: lerpLookAt, kind: "vector2", properties: { x: { kind: "number" }, y: { kind: "number" }, z: { kind: "number" } },
|
|
21
|
+
}),
|
|
22
|
+
zoom: Types.number(1, { min: 0.01, step: 0.1, unit: "×" }),
|
|
23
|
+
heading: Types.number(0, { step: 1, unit: "°" }),
|
|
24
|
+
orbit: Types.number(0, { step: 1, unit: "°" }),
|
|
25
|
+
elevation: Types.number(0, { step: 1, unit: "°" }),
|
|
26
|
+
dolly: Types.number(0, { step: 10 }),
|
|
27
|
+
orbitSpeed: Types.number(0),
|
|
28
|
+
};
|
|
29
|
+
/** The stage's 2.5D camera for one subtree: its children stand in one space, orbited in depth. */
|
|
30
|
+
export const OrbitCamera = component2d({
|
|
31
|
+
key: "orbitCamera",
|
|
32
|
+
state: orbit,
|
|
33
|
+
defaults: { width: "hug", height: "hug", perspective: 1000 },
|
|
34
|
+
commands: commandsFor(orbit, {
|
|
35
|
+
orbitTo: { args: ["orbit", "elevation"] },
|
|
36
|
+
dollyTo: { args: ["dolly"] },
|
|
37
|
+
zoomTo: { args: ["zoom"] },
|
|
38
|
+
panTo: { args: ["lookAt"] },
|
|
39
|
+
headingTo: { args: ["heading"] },
|
|
40
|
+
}),
|
|
41
|
+
render: (ctx, state) => ctx.space({
|
|
42
|
+
perspective: state.perspective,
|
|
43
|
+
orbit: state.orbit + state.orbitSpeed * ctx.time.total,
|
|
44
|
+
elevation: state.elevation,
|
|
45
|
+
dolly: state.dolly,
|
|
46
|
+
lookAt: state.lookAt,
|
|
47
|
+
zoom: state.zoom,
|
|
48
|
+
heading: state.heading,
|
|
49
|
+
viewportX: 0,
|
|
50
|
+
viewportY: 0,
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
/** Its children laid out in a box turned by `angle`, and turned with it: the box it reports is the turned one's bounds. */
|
|
54
|
+
export const RotatedBox = component2d({
|
|
55
|
+
key: "rotated-box",
|
|
56
|
+
state: { angle: Types.number(-90) },
|
|
57
|
+
defaults: { rotation: (state) => state.angle },
|
|
58
|
+
measure: (measurer, state, children) => {
|
|
59
|
+
const { cos, sin } = turn(state.angle);
|
|
60
|
+
const { width: w, height: h } = measurer.max;
|
|
61
|
+
const ortho = Math.abs(state.angle % 180) === 90;
|
|
62
|
+
const room = w !== undefined && h !== undefined
|
|
63
|
+
? { width: w * cos + h * sin, height: w * sin + h * cos }
|
|
64
|
+
: { width: ortho ? h : w, height: ortho ? w : h };
|
|
65
|
+
let width = 0;
|
|
66
|
+
let height = 0;
|
|
67
|
+
for (const child of children) {
|
|
68
|
+
const size = child.measure(room);
|
|
69
|
+
width = Math.max(width, size.width);
|
|
70
|
+
height = Math.max(height, size.height);
|
|
71
|
+
}
|
|
72
|
+
return { width: width * cos + height * sin, height: width * sin + height * cos };
|
|
73
|
+
},
|
|
74
|
+
layout: (box, state, children) => {
|
|
75
|
+
const { cos, sin } = turn(state.angle);
|
|
76
|
+
const turned = { x: 0, y: 0, width: box.width * cos + box.height * sin, height: box.width * sin + box.height * cos };
|
|
77
|
+
return Flow.layout(turned, state, children);
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
function turn(angle) {
|
|
81
|
+
const rad = angle * (Math.PI / 180);
|
|
82
|
+
return { cos: Math.abs(Math.cos(rad)), sin: Math.abs(Math.sin(rad)) };
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/component/builtins/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAe,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAC;AAC/C,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD,OAAO,KAAK,IAAI,MAAM,0BAA0B,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAC;AAEnD,kGAAkG;AAClG,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAC;IAC9B,GAAG,EAAE,QAAQ;IACb,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE;IACxE,QAAQ,EAAE,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC,QAAQ,EAAE;IAChD,OAAO,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnG,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,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AAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,EAAE,MAAM,EAAE,KAAK,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC;IACrF,CAAC;IACD,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC7B,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QACrH,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,KAAkC,EAAE,QAAQ,CAAC,CAAC;IAC7E,CAAC;CACJ,CAAC,CAAC;AAEH,SAAS,IAAI,CAAC,KAAa;IACvB,MAAM,GAAG,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IACpC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;AAC1E,CAAC","sourcesContent":["import { lerpLookAt, type LookAt } from \"@/attributes/layout/space3d\";\r\nimport type { NodeOf } from \"@/component/api\";\r\nimport { component2d } from \"@/component/component2d\";\r\nimport { commandsFor } from \"@/component/commands-for\";\r\nimport { Types } from \"@/component/types\";\r\nimport * as Aim from \"@/component/modules/aim\";\r\nimport * as Corners from \"@/component/modules/corners\";\r\nimport * as Flow from \"@/component/modules/flow\";\r\nimport * as Paint from \"@/component/modules/paint\";\r\n\r\n/** A framed viewport: painted like a rect, its children seen through a camera aimed inside it. */\r\nexport const Camera = component2d({\r\n key: \"camera\",\r\n state: { ...Paint.state, ...Flow.state, ...Aim.state, ...Corners.state },\r\n commands: { ...Paint.commands, ...Aim.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => Paint.draw(ctx, state, Corners.rect(ctx.size, state), { children: () => Aim.camera(ctx, state) }),\r\n});\r\n\r\nconst orbit = {\r\n lookAt: Types.custom<LookAt>({ x: 0, y: 0 }, {\r\n lerp: lerpLookAt, kind: \"vector2\", properties: { x: { kind: \"number\" }, y: { kind: \"number\" }, z: { kind: \"number\" } },\r\n }),\r\n zoom: Types.number(1, { min: 0.01, step: 0.1, unit: \"×\" }),\r\n heading: Types.number(0, { step: 1, unit: \"°\" }),\r\n orbit: Types.number(0, { step: 1, unit: \"°\" }),\r\n elevation: Types.number(0, { step: 1, unit: \"°\" }),\r\n dolly: Types.number(0, { step: 10 }),\r\n orbitSpeed: Types.number(0),\r\n};\r\n\r\n/** The stage's 2.5D camera for one subtree: its children stand in one space, orbited in depth. */\r\nexport const OrbitCamera = component2d({\r\n key: \"orbitCamera\",\r\n state: orbit,\r\n defaults: { width: \"hug\", height: \"hug\", perspective: 1000 },\r\n commands: commandsFor(orbit, {\r\n orbitTo: { args: [\"orbit\", \"elevation\"] },\r\n dollyTo: { args: [\"dolly\"] },\r\n zoomTo: { args: [\"zoom\"] },\r\n panTo: { args: [\"lookAt\"] },\r\n headingTo: { args: [\"heading\"] },\r\n }),\r\n render: (ctx, state) => ctx.space({\r\n perspective: state.perspective,\r\n orbit: state.orbit + state.orbitSpeed * ctx.time.total,\r\n elevation: state.elevation,\r\n dolly: state.dolly,\r\n lookAt: state.lookAt,\r\n zoom: state.zoom,\r\n heading: state.heading,\r\n viewportX: 0,\r\n viewportY: 0,\r\n }),\r\n});\r\n\r\n/** Its children laid out in a box turned by `angle`, and turned with it: the box it reports is the turned one's bounds. */\r\nexport const RotatedBox = component2d({\r\n key: \"rotated-box\",\r\n state: { angle: Types.number(-90) },\r\n defaults: { rotation: (state) => state.angle },\r\n measure: (measurer, state, children) => {\r\n const { cos, sin } = turn(state.angle);\r\n const { width: w, height: h } = measurer.max;\r\n const ortho = Math.abs(state.angle % 180) === 90;\r\n const room = w !== undefined && h !== undefined\r\n ? { width: w * cos + h * sin, height: w * sin + h * cos }\r\n : { width: ortho ? h : w, height: ortho ? w : h };\r\n let width = 0;\r\n let height = 0;\r\n for (const child of children) {\r\n const size = child.measure(room);\r\n width = Math.max(width, size.width);\r\n height = Math.max(height, size.height);\r\n }\r\n return { width: width * cos + height * sin, height: width * sin + height * cos };\r\n },\r\n layout: (box, state, children) => {\r\n const { cos, sin } = turn(state.angle);\r\n const turned = { x: 0, y: 0, width: box.width * cos + box.height * sin, height: box.width * sin + box.height * cos };\r\n return Flow.layout(turned, state as unknown as Flow.FlowState, children);\r\n },\r\n});\r\n\r\nfunction turn(angle: number): { cos: number; sin: number } {\r\n const rad = angle * (Math.PI / 180);\r\n return { cos: Math.abs(Math.cos(rad)), sin: Math.abs(Math.sin(rad)) };\r\n}\r\n\r\nexport type Camera = NodeOf<typeof Camera>;\r\nexport type OrbitCamera = NodeOf<typeof OrbitCamera>;\r\nexport type RotatedBox = NodeOf<typeof RotatedBox>;\r\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Alignment } from "../../attributes/layout/alignment.js";
|
|
2
|
+
import type { InsetsResolved } from "../../attributes/layout/insets.js";
|
|
3
|
+
import type { Vector2 } from "../../attributes/layout/vector2.js";
|
|
4
|
+
import { type AudioFilter } from "../../attributes/audio/filters/chain.js";
|
|
5
|
+
import type { AudioFilterItem } from "../../attributes/audio/filters/union.js";
|
|
6
|
+
import type { ImageFit, ImageMatrix } from "../../attributes/shape/fill/implementations/image.js";
|
|
7
|
+
import { type VideoAdjustment } from "../../attributes/shape/filters/chain.js";
|
|
8
|
+
import { type AnyFilter } from "../../attributes/shape/filters/registry.js";
|
|
9
|
+
import type { VideoSegment } from "../../nodes/media/video-node.js";
|
|
10
|
+
import type { NodeOf } from "../../component/api.js";
|
|
11
|
+
export declare const Video: import("../../component/api.js").Component<"video", import("../../component/api.js").Merge<import("../../component/api.js").Box2DState, {
|
|
12
|
+
readonly src: import("../../component/api.js").Type<string | undefined, string | undefined, false>;
|
|
13
|
+
readonly fit: import("../../component/api.js").Type<ImageFit | undefined, ImageFit | undefined, false>;
|
|
14
|
+
readonly crop: import("../../component/types.js").Attribute<import("../../attributes/layout/insets.js").InsetsProps, InsetsResolved>;
|
|
15
|
+
readonly zoom: number;
|
|
16
|
+
readonly anchor: import("../../component/types.js").Attribute<Alignment, Vector2>;
|
|
17
|
+
readonly matrix: import("../../component/api.js").Type<ImageMatrix | undefined, ImageMatrix | undefined, false>;
|
|
18
|
+
readonly filters: import("../../component/api.js").Type<VideoAdjustment, AnyFilter[], false>;
|
|
19
|
+
readonly playing: boolean;
|
|
20
|
+
readonly timestamp: import("../../component/api.js").Type<number | null | undefined, number | null | undefined, false>;
|
|
21
|
+
readonly trimStart: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
22
|
+
readonly trimEnd: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
23
|
+
readonly speed: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
24
|
+
readonly loop: import("../../component/api.js").Type<"reverse" | "none" | "forward" | undefined, "reverse" | "none" | "forward" | undefined, false>;
|
|
25
|
+
readonly duration: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
26
|
+
readonly volume: number;
|
|
27
|
+
readonly muted: boolean;
|
|
28
|
+
readonly audioFilters: import("../../component/api.js").Type<AudioFilter, AudioFilterItem[], false>;
|
|
29
|
+
readonly bus: import("../../component/api.js").Type<string | undefined, string | undefined, false>;
|
|
30
|
+
readonly segments: import("../../component/api.js").Type<readonly VideoSegment[], readonly VideoSegment[], false>;
|
|
31
|
+
readonly cornerRadius: import("../../component/types.js").Attribute<import("../../index.js").RectCornerRadius, import("../../index.js").CornerRadiusResolved>;
|
|
32
|
+
readonly cornerStyle: import("../../component/types.js").Attribute<import("../../index.js").RectCornerStyle, import("../../index.js").CornerStyleResolved>;
|
|
33
|
+
readonly flow: import("../../component/api.js").Type<import("../../index.js").FlowMode, import("../../index.js").FlowResolved, false>;
|
|
34
|
+
readonly gap: import("../../component/api.js").Type<import("../../index.js").GapSize, import("../../index.js").GapSize, false>;
|
|
35
|
+
readonly wrap: boolean;
|
|
36
|
+
readonly crossGap: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
37
|
+
readonly columns: import("../../component/api.js").Type<number, number, false>;
|
|
38
|
+
readonly align: import("../../component/types.js").Attribute<Alignment, Vector2>;
|
|
39
|
+
readonly fill: import("../../component/types.js").Attribute<import("../../index.js").Fill, import("../../attributes/shape/fill/union.js").FillResolved[]>;
|
|
40
|
+
readonly stroke: import("../../component/types.js").Attribute<import("../../index.js").Stroke, import("../../index.js").StrokeResolved[]>;
|
|
41
|
+
readonly shadow: import("../../component/types.js").Attribute<import("../../index.js").Shadow, import("../../index.js").ShadowResolved[]>;
|
|
42
|
+
readonly overlay: import("../../component/types.js").Attribute<import("../../index.js").Fill, import("../../attributes/shape/fill/union.js").FillResolved[]>;
|
|
43
|
+
readonly start: import("../../component/api.js").Type<number, number, false>;
|
|
44
|
+
readonly end: import("../../component/api.js").Type<number, number, false>;
|
|
45
|
+
}>, {
|
|
46
|
+
readonly play: {
|
|
47
|
+
readonly from: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
48
|
+
readonly volume: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
49
|
+
readonly speed: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
50
|
+
};
|
|
51
|
+
readonly fillTo: readonly ["fill"];
|
|
52
|
+
readonly strokeTo: readonly ["stroke"];
|
|
53
|
+
readonly shadowTo: readonly ["shadow"];
|
|
54
|
+
readonly overlayTo: readonly ["overlay"];
|
|
55
|
+
readonly progressTo: readonly ["start", "end"];
|
|
56
|
+
readonly flash: {
|
|
57
|
+
readonly portion: import("../../component/api.js").Type<number, number, false>;
|
|
58
|
+
};
|
|
59
|
+
}, null, import("../../index.js").Node2D<import("../../index.js").Node2DProps>, import("../../component/api.js").CallProps<import("../../component/api.js").Merge<import("../../component/api.js").Box2DState, {
|
|
60
|
+
readonly src: import("../../component/api.js").Type<string | undefined, string | undefined, false>;
|
|
61
|
+
readonly fit: import("../../component/api.js").Type<ImageFit | undefined, ImageFit | undefined, false>;
|
|
62
|
+
readonly crop: import("../../component/types.js").Attribute<import("../../attributes/layout/insets.js").InsetsProps, InsetsResolved>;
|
|
63
|
+
readonly zoom: number;
|
|
64
|
+
readonly anchor: import("../../component/types.js").Attribute<Alignment, Vector2>;
|
|
65
|
+
readonly matrix: import("../../component/api.js").Type<ImageMatrix | undefined, ImageMatrix | undefined, false>;
|
|
66
|
+
readonly filters: import("../../component/api.js").Type<VideoAdjustment, AnyFilter[], false>;
|
|
67
|
+
readonly playing: boolean;
|
|
68
|
+
readonly timestamp: import("../../component/api.js").Type<number | null | undefined, number | null | undefined, false>;
|
|
69
|
+
readonly trimStart: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
70
|
+
readonly trimEnd: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
71
|
+
readonly speed: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
72
|
+
readonly loop: import("../../component/api.js").Type<"reverse" | "none" | "forward" | undefined, "reverse" | "none" | "forward" | undefined, false>;
|
|
73
|
+
readonly duration: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
74
|
+
readonly volume: number;
|
|
75
|
+
readonly muted: boolean;
|
|
76
|
+
readonly audioFilters: import("../../component/api.js").Type<AudioFilter, AudioFilterItem[], false>;
|
|
77
|
+
readonly bus: import("../../component/api.js").Type<string | undefined, string | undefined, false>;
|
|
78
|
+
readonly segments: import("../../component/api.js").Type<readonly VideoSegment[], readonly VideoSegment[], false>;
|
|
79
|
+
readonly cornerRadius: import("../../component/types.js").Attribute<import("../../index.js").RectCornerRadius, import("../../index.js").CornerRadiusResolved>;
|
|
80
|
+
readonly cornerStyle: import("../../component/types.js").Attribute<import("../../index.js").RectCornerStyle, import("../../index.js").CornerStyleResolved>;
|
|
81
|
+
readonly flow: import("../../component/api.js").Type<import("../../index.js").FlowMode, import("../../index.js").FlowResolved, false>;
|
|
82
|
+
readonly gap: import("../../component/api.js").Type<import("../../index.js").GapSize, import("../../index.js").GapSize, false>;
|
|
83
|
+
readonly wrap: boolean;
|
|
84
|
+
readonly crossGap: import("../../component/api.js").Type<number | undefined, number | undefined, false>;
|
|
85
|
+
readonly columns: import("../../component/api.js").Type<number, number, false>;
|
|
86
|
+
readonly align: import("../../component/types.js").Attribute<Alignment, Vector2>;
|
|
87
|
+
readonly fill: import("../../component/types.js").Attribute<import("../../index.js").Fill, import("../../attributes/shape/fill/union.js").FillResolved[]>;
|
|
88
|
+
readonly stroke: import("../../component/types.js").Attribute<import("../../index.js").Stroke, import("../../index.js").StrokeResolved[]>;
|
|
89
|
+
readonly shadow: import("../../component/types.js").Attribute<import("../../index.js").Shadow, import("../../index.js").ShadowResolved[]>;
|
|
90
|
+
readonly overlay: import("../../component/types.js").Attribute<import("../../index.js").Fill, import("../../attributes/shape/fill/union.js").FillResolved[]>;
|
|
91
|
+
readonly start: import("../../component/api.js").Type<number, number, false>;
|
|
92
|
+
readonly end: import("../../component/api.js").Type<number, number, false>;
|
|
93
|
+
}>, null>>;
|
|
94
|
+
export type Video = NodeOf<typeof Video>;
|
|
95
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/component/builtins/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAqC,KAAK,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACvG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAI3F,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,MAAM,EAAU,MAAM,iBAAiB,CAAC;AA8FtD,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmDhB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { AudioFilters, resolveAudioFilters } from "../../attributes/audio/filters/chain.js";
|
|
2
|
+
import { sourceTimeFor } from "../../attributes/shape/fill/implementations/video.js";
|
|
3
|
+
import { resolveFill, UNSET_MEDIA_FILL } from "../../attributes/shape/fill/registry.js";
|
|
4
|
+
import { resolveChainAdjustments } from "../../attributes/shape/filters/chain.js";
|
|
5
|
+
import { lerpFilterArray } from "../../attributes/shape/filters/registry.js";
|
|
6
|
+
import { Graphics2D } from "../../render/graphics2d.js";
|
|
7
|
+
import { component2d } from "../../component/component2d.js";
|
|
8
|
+
import { Types } from "../../component/types.js";
|
|
9
|
+
import * as Corners from "../../component/modules/corners.js";
|
|
10
|
+
import * as Flow from "../../component/modules/flow.js";
|
|
11
|
+
import * as Paint from "../../component/modules/paint.js";
|
|
12
|
+
import { internalsOf } from "../../component/views.js";
|
|
13
|
+
/**
|
|
14
|
+
* Video: a rect painted with a playing picture under its fill, and the
|
|
15
|
+
* picture's sound. Its sound plays from `play`; a `video` row with no `play`
|
|
16
|
+
* of its own gets one per segment, or one over its span while it plays.
|
|
17
|
+
*/
|
|
18
|
+
const video = {
|
|
19
|
+
src: Types.custom(undefined),
|
|
20
|
+
fit: Types.custom(undefined),
|
|
21
|
+
crop: Types.insets,
|
|
22
|
+
zoom: 1,
|
|
23
|
+
anchor: Types.alignment,
|
|
24
|
+
matrix: Types.custom(undefined),
|
|
25
|
+
filters: Types.custom([], {
|
|
26
|
+
resolve: (v) => resolveChainAdjustments(v),
|
|
27
|
+
lerp: lerpFilterArray,
|
|
28
|
+
}),
|
|
29
|
+
playing: true,
|
|
30
|
+
timestamp: Types.custom(undefined),
|
|
31
|
+
trimStart: Types.custom(undefined),
|
|
32
|
+
trimEnd: Types.custom(undefined),
|
|
33
|
+
speed: Types.custom(undefined),
|
|
34
|
+
loop: Types.custom(undefined),
|
|
35
|
+
duration: Types.custom(undefined),
|
|
36
|
+
volume: 1,
|
|
37
|
+
muted: false,
|
|
38
|
+
audioFilters: Types.custom([], { resolve: (v) => resolveAudioFilters(v) }),
|
|
39
|
+
bus: Types.custom(undefined),
|
|
40
|
+
segments: Types.custom([]),
|
|
41
|
+
};
|
|
42
|
+
/** Source seconds played by `elapsed` clip seconds into the segments, or `null` without any. */
|
|
43
|
+
function playedAt(s, elapsed) {
|
|
44
|
+
if (s.segments.length === 0)
|
|
45
|
+
return null;
|
|
46
|
+
let played = 0;
|
|
47
|
+
for (const segment of s.segments) {
|
|
48
|
+
if (elapsed <= segment.at)
|
|
49
|
+
break;
|
|
50
|
+
played += Math.min(elapsed - segment.at, segment.duration) * (segment.speed ?? s.speed ?? 1);
|
|
51
|
+
}
|
|
52
|
+
return played;
|
|
53
|
+
}
|
|
54
|
+
function scheduledTimestamp(s, elapsed) {
|
|
55
|
+
const played = playedAt(s, elapsed);
|
|
56
|
+
if (played === null)
|
|
57
|
+
return undefined;
|
|
58
|
+
const start = s.trimStart ?? 0;
|
|
59
|
+
const first = s.segments[0];
|
|
60
|
+
return sourceTimeFor(played + (first ? first.from - start : 0), start, s.trimEnd ?? Infinity, s.loop, s.duration);
|
|
61
|
+
}
|
|
62
|
+
const pictures = new WeakMap();
|
|
63
|
+
/** The frame to paint, resolved once per change of what it depends on. */
|
|
64
|
+
function pictureOf(host, s, elapsed) {
|
|
65
|
+
if (!s.src) {
|
|
66
|
+
pictures.delete(host);
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const scheduled = scheduledTimestamp(s, elapsed);
|
|
70
|
+
const crop = s.crop;
|
|
71
|
+
const anchor = s.anchor;
|
|
72
|
+
const key = [
|
|
73
|
+
s.src, s.fit ?? "", s.zoom, s.playing ? 1 : 0, crop.left, crop.right, crop.top, crop.bottom, anchor.x, anchor.y,
|
|
74
|
+
s.timestamp ?? "", s.trimStart ?? "", s.trimEnd ?? "", s.speed ?? "", s.loop ?? "", s.duration ?? "", scheduled ?? "",
|
|
75
|
+
].join("|");
|
|
76
|
+
const kept = pictures.get(host);
|
|
77
|
+
if (kept && kept.key === key)
|
|
78
|
+
return kept.fill;
|
|
79
|
+
const prop = {
|
|
80
|
+
type: "video", src: s.src, fit: s.fit, crop: s.crop, zoom: s.zoom, anchor: s.anchor, matrix: s.matrix,
|
|
81
|
+
filters: s.filters, playing: s.playing, timestamp: s.timestamp ?? scheduled,
|
|
82
|
+
trimStart: s.trimStart, trimEnd: s.trimEnd, speed: s.speed, loop: s.loop, duration: s.duration,
|
|
83
|
+
};
|
|
84
|
+
const fill = resolveFill(prop);
|
|
85
|
+
pictures.set(host, { key, fill });
|
|
86
|
+
return fill;
|
|
87
|
+
}
|
|
88
|
+
function soundFilters(s, speed) {
|
|
89
|
+
const filters = [];
|
|
90
|
+
if (speed !== 1)
|
|
91
|
+
filters.push(...resolveAudioFilters(AudioFilters.speed(speed)));
|
|
92
|
+
filters.push(...s.audioFilters);
|
|
93
|
+
return filters;
|
|
94
|
+
}
|
|
95
|
+
export const Video = component2d({
|
|
96
|
+
key: "video",
|
|
97
|
+
state: { ...Paint.state, ...Flow.state, ...Corners.state, ...video },
|
|
98
|
+
commands: {
|
|
99
|
+
...Paint.commands,
|
|
100
|
+
/** Its sound: from `from` in the source for a segment, or as it plays. Cut when the command ends. */
|
|
101
|
+
play: {
|
|
102
|
+
args: {
|
|
103
|
+
from: Types.custom(undefined),
|
|
104
|
+
volume: Types.custom(undefined),
|
|
105
|
+
speed: Types.custom(undefined),
|
|
106
|
+
},
|
|
107
|
+
run: (timeline, state) => {
|
|
108
|
+
const s = state;
|
|
109
|
+
const segment = timeline.args.from !== undefined;
|
|
110
|
+
if (!s.src || s.muted || (!segment && !s.playing))
|
|
111
|
+
return timeline.together([]);
|
|
112
|
+
const speed = timeline.args.speed ?? s.speed ?? 1;
|
|
113
|
+
const loop = !segment && (s.loop ?? "none") !== "none";
|
|
114
|
+
return timeline.sound(s.src, {
|
|
115
|
+
volume: timeline.args.volume ?? s.volume,
|
|
116
|
+
loop,
|
|
117
|
+
trimStart: segment ? timeline.args.from : s.trimStart,
|
|
118
|
+
trimEnd: s.trimEnd,
|
|
119
|
+
filters: soundFilters(s, speed),
|
|
120
|
+
bus: s.bus,
|
|
121
|
+
optional: true,
|
|
122
|
+
closed: !loop,
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
load: (loader, state) => {
|
|
128
|
+
if (!state.src)
|
|
129
|
+
return;
|
|
130
|
+
loader.fill(resolveFill({
|
|
131
|
+
type: "video", src: state.src, filters: state.filters, trimStart: state.trimStart, trimEnd: state.trimEnd,
|
|
132
|
+
}));
|
|
133
|
+
},
|
|
134
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
135
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
136
|
+
render: (ctx, state) => {
|
|
137
|
+
const s = state;
|
|
138
|
+
const picture = pictureOf(internalsOf(ctx).host, s, ctx.time.elapsed);
|
|
139
|
+
const outline = { width: ctx.size.width, height: ctx.size.height, cornerRadius: s.cornerRadius, cornerStyle: s.cornerStyle, start: s.start, end: s.end };
|
|
140
|
+
Paint.draw(ctx, state, Corners.rect(ctx.size, state), {
|
|
141
|
+
fill: [(picture ?? UNSET_MEDIA_FILL), ...state.fill],
|
|
142
|
+
// The overlay lies on the picture only, masked by it.
|
|
143
|
+
overlay: () => (picture
|
|
144
|
+
? new Graphics2D().mask().rect(outline).fill([picture]).applyMask().rect(outline).fill(state.overlay).endMask()
|
|
145
|
+
: null),
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=media.js.map
|