reframe-video 0.1.0 → 0.1.2
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/assets/sfx/LICENSE.md +5 -0
- package/assets/sfx/bgm-song21.mp3 +0 -0
- package/assets/sfx/pop.wav +0 -0
- package/assets/sfx/rise.wav +0 -0
- package/assets/sfx/shimmer.wav +0 -0
- package/assets/sfx/thud.wav +0 -0
- package/assets/sfx/tick.wav +0 -0
- package/assets/sfx/whoosh.wav +0 -0
- package/dist/analyze.js +44 -1
- package/dist/bin.js +371 -35
- package/dist/browserEntry.js +311 -8
- package/dist/cli.js +305 -21
- package/dist/index.js +566 -16
- package/dist/renderer-canvas.js +58 -3
- package/dist/trace-cli.js +677 -0
- package/dist/types/assets.d.ts +9 -0
- package/dist/types/compile.d.ts +15 -1
- package/dist/types/compose.d.ts +12 -2
- package/dist/types/dsl.d.ts +30 -1
- package/dist/types/evaluate.d.ts +17 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/ir.d.ts +82 -1
- package/dist/types/motion.d.ts +54 -0
- package/dist/types/path.d.ts +15 -0
- package/dist/types/presets.d.ts +41 -0
- package/guides/edsl-guide.md +24 -0
- package/package.json +1 -1
- package/preview/src/main.ts +111 -6
- package/preview/src/panel.ts +37 -3
- package/preview/src/store.ts +28 -2
- package/preview/src/virtual.d.ts +9 -1
- package/preview/vite.config.ts +3 -2
package/dist/renderer-canvas.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ../renderer-canvas/src/index.ts
|
|
2
2
|
import { evaluate } from "@reframe/core";
|
|
3
|
-
function renderFrame(ctx, compiled, t) {
|
|
3
|
+
function renderFrame(ctx, compiled, t, images) {
|
|
4
4
|
const { size, background } = compiled.ir;
|
|
5
5
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
6
6
|
ctx.clearRect(0, 0, size.width, size.height);
|
|
@@ -8,9 +8,9 @@ function renderFrame(ctx, compiled, t) {
|
|
|
8
8
|
ctx.fillStyle = background;
|
|
9
9
|
ctx.fillRect(0, 0, size.width, size.height);
|
|
10
10
|
}
|
|
11
|
-
drawDisplayList(ctx, evaluate(compiled, t));
|
|
11
|
+
drawDisplayList(ctx, evaluate(compiled, t), images);
|
|
12
12
|
}
|
|
13
|
-
function drawDisplayList(ctx, ops) {
|
|
13
|
+
function drawDisplayList(ctx, ops, images) {
|
|
14
14
|
for (const op of ops) {
|
|
15
15
|
ctx.save();
|
|
16
16
|
ctx.setTransform(...op.transform);
|
|
@@ -66,6 +66,48 @@ function drawDisplayList(ctx, ops) {
|
|
|
66
66
|
ctx.stroke();
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
|
+
case "image": {
|
|
70
|
+
const img = images?.get(op.src);
|
|
71
|
+
if (img) {
|
|
72
|
+
ctx.drawImage(img, op.offsetX, op.offsetY, op.width, op.height);
|
|
73
|
+
} else {
|
|
74
|
+
ctx.fillStyle = "#2A2A30";
|
|
75
|
+
ctx.fillRect(op.offsetX, op.offsetY, op.width, op.height);
|
|
76
|
+
ctx.strokeStyle = "#FF00FF";
|
|
77
|
+
ctx.lineWidth = 2;
|
|
78
|
+
ctx.strokeRect(op.offsetX, op.offsetY, op.width, op.height);
|
|
79
|
+
ctx.beginPath();
|
|
80
|
+
ctx.moveTo(op.offsetX, op.offsetY);
|
|
81
|
+
ctx.lineTo(op.offsetX + op.width, op.offsetY + op.height);
|
|
82
|
+
ctx.moveTo(op.offsetX + op.width, op.offsetY);
|
|
83
|
+
ctx.lineTo(op.offsetX, op.offsetY + op.height);
|
|
84
|
+
ctx.stroke();
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "path": {
|
|
89
|
+
const p = new Path2D(op.d);
|
|
90
|
+
if (op.fill) {
|
|
91
|
+
ctx.fillStyle = op.fill;
|
|
92
|
+
ctx.fill(p);
|
|
93
|
+
}
|
|
94
|
+
if (op.stroke && (op.strokeWidth ?? 1) > 0) {
|
|
95
|
+
ctx.strokeStyle = op.stroke;
|
|
96
|
+
ctx.lineWidth = op.strokeWidth ?? 1;
|
|
97
|
+
ctx.lineJoin = "round";
|
|
98
|
+
ctx.lineCap = "round";
|
|
99
|
+
if (op.progress < 1) {
|
|
100
|
+
const len = pathLength(op.d);
|
|
101
|
+
if (len > 0) {
|
|
102
|
+
ctx.setLineDash([len, len]);
|
|
103
|
+
ctx.lineDashOffset = len * (1 - op.progress);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
ctx.stroke(p);
|
|
107
|
+
ctx.setLineDash([]);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
69
111
|
case "text": {
|
|
70
112
|
ctx.font = `${op.fontWeight} ${op.fontSize}px ${quoteFamily(op.fontFamily)}`;
|
|
71
113
|
if (op.letterSpacing) ctx.letterSpacing = `${op.letterSpacing}px`;
|
|
@@ -83,6 +125,19 @@ function drawDisplayList(ctx, ops) {
|
|
|
83
125
|
function quoteFamily(family) {
|
|
84
126
|
return family.includes(" ") && !family.includes('"') ? `"${family}"` : family;
|
|
85
127
|
}
|
|
128
|
+
var pathLengthCache = /* @__PURE__ */ new Map();
|
|
129
|
+
function pathLength(d) {
|
|
130
|
+
const hit = pathLengthCache.get(d);
|
|
131
|
+
if (hit !== void 0) return hit;
|
|
132
|
+
let len = 0;
|
|
133
|
+
if (typeof document !== "undefined") {
|
|
134
|
+
const el = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
135
|
+
el.setAttribute("d", d);
|
|
136
|
+
len = el.getTotalLength();
|
|
137
|
+
}
|
|
138
|
+
pathLengthCache.set(d, len);
|
|
139
|
+
return len;
|
|
140
|
+
}
|
|
86
141
|
export {
|
|
87
142
|
drawDisplayList,
|
|
88
143
|
renderFrame
|