@remotion/transitions 4.0.496 → 4.0.497
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/dist/TransitionSeries.d.ts +2 -2
- package/dist/TransitionSeries.js +1 -0
- package/dist/esm/book-flip.mjs +96 -24
- package/dist/esm/cross-zoom.mjs +96 -24
- package/dist/esm/crosswarp.mjs +96 -24
- package/dist/esm/dissolve.mjs +96 -24
- package/dist/esm/dreamy-zoom.mjs +96 -24
- package/dist/esm/film-burn.mjs +96 -24
- package/dist/esm/index.mjs +106 -33
- package/dist/esm/linear-blur.mjs +96 -24
- package/dist/esm/ripple.mjs +96 -24
- package/dist/esm/swap.mjs +96 -24
- package/dist/esm/zoom-blur.mjs +96 -24
- package/dist/esm/zoom-in-out.mjs +96 -24
- package/dist/html-in-canvas-presentation.d.ts +2 -2
- package/dist/html-in-canvas-presentation.js +81 -16
- package/dist/presentations/book-flip.js +3 -2
- package/dist/presentations/cross-zoom.js +3 -2
- package/dist/presentations/crosswarp.js +3 -2
- package/dist/presentations/dissolve.js +3 -2
- package/dist/presentations/dreamy-zoom.js +3 -2
- package/dist/presentations/film-burn.js +3 -2
- package/dist/presentations/linear-blur.js +3 -2
- package/dist/presentations/ripple.js +3 -2
- package/dist/presentations/swap.js +3 -2
- package/dist/presentations/upload-element-image.d.ts +1 -0
- package/dist/presentations/upload-element-image.js +7 -0
- package/dist/presentations/zoom-blur.js +3 -2
- package/dist/presentations/zoom-in-out.js +3 -2
- package/dist/types.d.ts +1 -1
- package/package.json +8 -8
package/dist/esm/zoom-in-out.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Internals,
|
|
8
8
|
useDelayRender
|
|
9
9
|
} from "remotion";
|
|
10
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
var HtmlInCanvasPresentation = ({
|
|
12
12
|
children,
|
|
13
13
|
onElementImage,
|
|
@@ -23,6 +23,7 @@ var HtmlInCanvasPresentation = ({
|
|
|
23
23
|
throw new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
|
|
24
24
|
}
|
|
25
25
|
const canvasRef = useRef(null);
|
|
26
|
+
const outputCanvasRef = useRef(null);
|
|
26
27
|
const canvasSubtreeStyle = useMemo(() => {
|
|
27
28
|
return {
|
|
28
29
|
width: "100%",
|
|
@@ -34,7 +35,21 @@ var HtmlInCanvasPresentation = ({
|
|
|
34
35
|
bottom: 0
|
|
35
36
|
};
|
|
36
37
|
}, []);
|
|
37
|
-
const
|
|
38
|
+
const outputCanvasStyle = useMemo(() => {
|
|
39
|
+
return {
|
|
40
|
+
width: "100%",
|
|
41
|
+
height: "100%",
|
|
42
|
+
position: "absolute",
|
|
43
|
+
top: 0,
|
|
44
|
+
left: 0,
|
|
45
|
+
right: 0,
|
|
46
|
+
bottom: 0,
|
|
47
|
+
pointerEvents: "none"
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
const captureCanvasRef = useRef(null);
|
|
51
|
+
const captureContextRef = useRef(null);
|
|
52
|
+
const [shaderCanvas] = useState(() => new OffscreenCanvas(1, 1));
|
|
38
53
|
const passedPropsRef = useRef(passedProps);
|
|
39
54
|
passedPropsRef.current = passedProps;
|
|
40
55
|
const memoizedEffects = Internals.useMemoizedEffects({
|
|
@@ -43,33 +58,58 @@ var HtmlInCanvasPresentation = ({
|
|
|
43
58
|
});
|
|
44
59
|
const effectsRef = useRef(memoizedEffects);
|
|
45
60
|
effectsRef.current = memoizedEffects;
|
|
46
|
-
const [instance] = useState(() => shader(
|
|
61
|
+
const [instance] = useState(() => shader(shaderCanvas));
|
|
47
62
|
useLayoutEffect(() => {
|
|
63
|
+
const canvas = canvasRef.current;
|
|
64
|
+
if (!canvas) {
|
|
65
|
+
return () => {
|
|
66
|
+
instance.cleanup();
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const captureCanvas = canvas.transferControlToOffscreen();
|
|
70
|
+
const captureContext = captureCanvas.getContext("2d");
|
|
71
|
+
if (!captureContext) {
|
|
72
|
+
throw new Error("Failed to create capture canvas context");
|
|
73
|
+
}
|
|
74
|
+
captureCanvasRef.current = captureCanvas;
|
|
75
|
+
captureContextRef.current = captureContext;
|
|
48
76
|
return () => {
|
|
49
77
|
instance.cleanup();
|
|
78
|
+
captureCanvasRef.current = null;
|
|
79
|
+
captureContextRef.current = null;
|
|
50
80
|
};
|
|
51
|
-
}, [
|
|
81
|
+
}, [instance]);
|
|
52
82
|
const chainState = Internals.useEffectChainState();
|
|
53
83
|
const { delayRender, continueRender } = useDelayRender();
|
|
54
84
|
const draw = useCallback(async (prevImage, nextImage, progress) => {
|
|
55
|
-
|
|
85
|
+
const outputCanvas = outputCanvasRef.current;
|
|
86
|
+
if (!outputCanvas) {
|
|
56
87
|
throw new Error("Canvas not found");
|
|
57
88
|
}
|
|
58
89
|
const handle = delayRender("onPaint");
|
|
90
|
+
const clearOutput = () => {
|
|
91
|
+
const context = outputCanvas.getContext("2d");
|
|
92
|
+
if (!context) {
|
|
93
|
+
throw new Error("Failed to create output canvas context");
|
|
94
|
+
}
|
|
95
|
+
context.clearRect(0, 0, outputCanvas.width, outputCanvas.height);
|
|
96
|
+
};
|
|
59
97
|
if (!prevImage && !nextImage) {
|
|
60
|
-
continueRender(handle);
|
|
61
98
|
instance.clear();
|
|
99
|
+
clearOutput();
|
|
100
|
+
continueRender(handle);
|
|
62
101
|
return;
|
|
63
102
|
}
|
|
64
103
|
const width = prevImage?.width ?? nextImage?.width ?? 0;
|
|
65
104
|
const height = prevImage?.height ?? nextImage?.height ?? 0;
|
|
66
105
|
if (width === 0 || height === 0) {
|
|
67
|
-
continueRender(handle);
|
|
68
106
|
instance.clear();
|
|
107
|
+
clearOutput();
|
|
108
|
+
continueRender(handle);
|
|
69
109
|
return;
|
|
70
110
|
}
|
|
71
|
-
|
|
72
|
-
|
|
111
|
+
shaderCanvas.width = width;
|
|
112
|
+
shaderCanvas.height = height;
|
|
73
113
|
instance.draw({
|
|
74
114
|
prevImage,
|
|
75
115
|
nextImage,
|
|
@@ -80,14 +120,14 @@ var HtmlInCanvasPresentation = ({
|
|
|
80
120
|
});
|
|
81
121
|
await Internals.runEffectChain({
|
|
82
122
|
state: chainState.get(width, height),
|
|
83
|
-
source:
|
|
123
|
+
source: shaderCanvas,
|
|
84
124
|
effects: effectsRef.current ?? [],
|
|
85
125
|
width,
|
|
86
126
|
height,
|
|
87
|
-
output:
|
|
127
|
+
output: outputCanvas
|
|
88
128
|
});
|
|
89
129
|
continueRender(handle);
|
|
90
|
-
}, [chainState,
|
|
130
|
+
}, [chainState, continueRender, delayRender, instance, shaderCanvas]);
|
|
91
131
|
const passThrough = bothEnteringAndExiting && presentationDirection === "exiting";
|
|
92
132
|
useLayoutEffect(() => {
|
|
93
133
|
if (passThrough) {
|
|
@@ -100,11 +140,19 @@ var HtmlInCanvasPresentation = ({
|
|
|
100
140
|
canvas.layoutSubtree = true;
|
|
101
141
|
const onPaint = () => {
|
|
102
142
|
const firstChild = canvas.firstChild;
|
|
103
|
-
|
|
143
|
+
const captureCanvas = captureCanvasRef.current;
|
|
144
|
+
const captureContext = captureContextRef.current;
|
|
145
|
+
if (!firstChild || !captureCanvas || !captureContext) {
|
|
104
146
|
return;
|
|
105
147
|
}
|
|
106
148
|
const elementImage = canvas.captureElementImage(firstChild);
|
|
107
|
-
|
|
149
|
+
try {
|
|
150
|
+
captureContext.reset();
|
|
151
|
+
captureContext.drawElementImage(elementImage, 0, 0);
|
|
152
|
+
} finally {
|
|
153
|
+
elementImage.close();
|
|
154
|
+
}
|
|
155
|
+
onElementImage(captureCanvas, draw);
|
|
108
156
|
};
|
|
109
157
|
canvas.addEventListener("paint", onPaint);
|
|
110
158
|
return () => {
|
|
@@ -138,20 +186,39 @@ var HtmlInCanvasPresentation = ({
|
|
|
138
186
|
return;
|
|
139
187
|
}
|
|
140
188
|
const observer = new ResizeObserver(([entry]) => {
|
|
141
|
-
|
|
142
|
-
|
|
189
|
+
const outputCanvas = outputCanvasRef.current;
|
|
190
|
+
const captureCanvas = captureCanvasRef.current;
|
|
191
|
+
if (!outputCanvas || !captureCanvas) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const width = entry.devicePixelContentBoxSize[0].inlineSize;
|
|
195
|
+
const height = entry.devicePixelContentBoxSize[0].blockSize;
|
|
196
|
+
captureCanvas.width = width;
|
|
197
|
+
captureCanvas.height = height;
|
|
198
|
+
outputCanvas.width = width;
|
|
199
|
+
outputCanvas.height = height;
|
|
200
|
+
canvas.requestPaint?.();
|
|
143
201
|
});
|
|
144
202
|
observer.observe(canvas, { box: "device-pixel-content-box" });
|
|
203
|
+
return () => {
|
|
204
|
+
observer.disconnect();
|
|
205
|
+
};
|
|
145
206
|
}, [passThrough]);
|
|
146
207
|
if (passThrough) {
|
|
147
208
|
return children;
|
|
148
209
|
}
|
|
149
|
-
return /* @__PURE__ */
|
|
150
|
-
children:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
210
|
+
return /* @__PURE__ */ jsxs(AbsoluteFill, {
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ jsx("canvas", {
|
|
213
|
+
ref: canvasRef,
|
|
214
|
+
style: canvasSubtreeStyle,
|
|
215
|
+
children
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ jsx("canvas", {
|
|
218
|
+
ref: outputCanvasRef,
|
|
219
|
+
style: outputCanvasStyle
|
|
220
|
+
})
|
|
221
|
+
]
|
|
155
222
|
});
|
|
156
223
|
};
|
|
157
224
|
var makeHtmlInCanvasPresentation = (shader) => {
|
|
@@ -173,6 +240,11 @@ var makeHtmlInCanvasPresentation = (shader) => {
|
|
|
173
240
|
};
|
|
174
241
|
};
|
|
175
242
|
|
|
243
|
+
// src/presentations/upload-element-image.ts
|
|
244
|
+
var uploadElementImage = (gl, elementImage) => {
|
|
245
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, elementImage);
|
|
246
|
+
};
|
|
247
|
+
|
|
176
248
|
// src/presentations/zoom-in-out.tsx
|
|
177
249
|
var VERTEX_SHADER = `#version 300 es
|
|
178
250
|
in vec2 a_pos;
|
|
@@ -302,13 +374,13 @@ var zoomInOutShader = (canvas) => {
|
|
|
302
374
|
gl.activeTexture(gl.TEXTURE0);
|
|
303
375
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
304
376
|
if (prevImage) {
|
|
305
|
-
|
|
377
|
+
uploadElementImage(gl, prevImage);
|
|
306
378
|
}
|
|
307
379
|
gl.uniform1i(uPrev, 0);
|
|
308
380
|
gl.activeTexture(gl.TEXTURE1);
|
|
309
381
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
310
382
|
if (nextImage) {
|
|
311
|
-
|
|
383
|
+
uploadElementImage(gl, nextImage);
|
|
312
384
|
}
|
|
313
385
|
gl.uniform1i(uNext, 1);
|
|
314
386
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -5,8 +5,8 @@ export declare const HtmlInCanvasPresentation: <TPassedProps extends Record<stri
|
|
|
5
5
|
readonly effects?: EffectsProp | undefined;
|
|
6
6
|
}) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
7
7
|
export type HtmlInCanvasShaderDrawParams<Props> = {
|
|
8
|
-
prevImage:
|
|
9
|
-
nextImage:
|
|
8
|
+
prevImage: OffscreenCanvas | null;
|
|
9
|
+
nextImage: OffscreenCanvas | null;
|
|
10
10
|
width: number;
|
|
11
11
|
height: number;
|
|
12
12
|
time: number;
|
|
@@ -9,6 +9,7 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
9
9
|
throw new Error(remotion_1.HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
|
|
10
10
|
}
|
|
11
11
|
const canvasRef = (0, react_1.useRef)(null);
|
|
12
|
+
const outputCanvasRef = (0, react_1.useRef)(null);
|
|
12
13
|
const canvasSubtreeStyle = (0, react_1.useMemo)(() => {
|
|
13
14
|
return {
|
|
14
15
|
width: '100%',
|
|
@@ -20,7 +21,21 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
20
21
|
bottom: 0,
|
|
21
22
|
};
|
|
22
23
|
}, []);
|
|
23
|
-
const
|
|
24
|
+
const outputCanvasStyle = (0, react_1.useMemo)(() => {
|
|
25
|
+
return {
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
top: 0,
|
|
30
|
+
left: 0,
|
|
31
|
+
right: 0,
|
|
32
|
+
bottom: 0,
|
|
33
|
+
pointerEvents: 'none',
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
const captureCanvasRef = (0, react_1.useRef)(null);
|
|
37
|
+
const captureContextRef = (0, react_1.useRef)(null);
|
|
38
|
+
const [shaderCanvas] = (0, react_1.useState)(() => new OffscreenCanvas(1, 1));
|
|
24
39
|
const passedPropsRef = (0, react_1.useRef)(passedProps);
|
|
25
40
|
passedPropsRef.current = passedProps;
|
|
26
41
|
const memoizedEffects = remotion_1.Internals.useMemoizedEffects({
|
|
@@ -29,34 +44,59 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
29
44
|
});
|
|
30
45
|
const effectsRef = (0, react_1.useRef)(memoizedEffects);
|
|
31
46
|
effectsRef.current = memoizedEffects;
|
|
32
|
-
const [instance] = (0, react_1.useState)(() => shader(
|
|
47
|
+
const [instance] = (0, react_1.useState)(() => shader(shaderCanvas));
|
|
33
48
|
(0, react_1.useLayoutEffect)(() => {
|
|
49
|
+
const canvas = canvasRef.current;
|
|
50
|
+
if (!canvas) {
|
|
51
|
+
return () => {
|
|
52
|
+
instance.cleanup();
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const captureCanvas = canvas.transferControlToOffscreen();
|
|
56
|
+
const captureContext = captureCanvas.getContext('2d');
|
|
57
|
+
if (!captureContext) {
|
|
58
|
+
throw new Error('Failed to create capture canvas context');
|
|
59
|
+
}
|
|
60
|
+
captureCanvasRef.current = captureCanvas;
|
|
61
|
+
captureContextRef.current = captureContext;
|
|
34
62
|
return () => {
|
|
35
63
|
instance.cleanup();
|
|
64
|
+
captureCanvasRef.current = null;
|
|
65
|
+
captureContextRef.current = null;
|
|
36
66
|
};
|
|
37
|
-
}, [
|
|
67
|
+
}, [instance]);
|
|
38
68
|
const chainState = remotion_1.Internals.useEffectChainState();
|
|
39
69
|
const { delayRender, continueRender } = (0, remotion_1.useDelayRender)();
|
|
40
70
|
const draw = (0, react_1.useCallback)(async (prevImage, nextImage, progress) => {
|
|
41
71
|
var _a, _b, _c, _d, _e;
|
|
42
|
-
|
|
72
|
+
const outputCanvas = outputCanvasRef.current;
|
|
73
|
+
if (!outputCanvas) {
|
|
43
74
|
throw new Error('Canvas not found');
|
|
44
75
|
}
|
|
45
76
|
const handle = delayRender('onPaint');
|
|
77
|
+
const clearOutput = () => {
|
|
78
|
+
const context = outputCanvas.getContext('2d');
|
|
79
|
+
if (!context) {
|
|
80
|
+
throw new Error('Failed to create output canvas context');
|
|
81
|
+
}
|
|
82
|
+
context.clearRect(0, 0, outputCanvas.width, outputCanvas.height);
|
|
83
|
+
};
|
|
46
84
|
if (!prevImage && !nextImage) {
|
|
47
|
-
continueRender(handle);
|
|
48
85
|
instance.clear();
|
|
86
|
+
clearOutput();
|
|
87
|
+
continueRender(handle);
|
|
49
88
|
return;
|
|
50
89
|
}
|
|
51
90
|
const width = (_b = (_a = prevImage === null || prevImage === void 0 ? void 0 : prevImage.width) !== null && _a !== void 0 ? _a : nextImage === null || nextImage === void 0 ? void 0 : nextImage.width) !== null && _b !== void 0 ? _b : 0;
|
|
52
91
|
const height = (_d = (_c = prevImage === null || prevImage === void 0 ? void 0 : prevImage.height) !== null && _c !== void 0 ? _c : nextImage === null || nextImage === void 0 ? void 0 : nextImage.height) !== null && _d !== void 0 ? _d : 0;
|
|
53
92
|
if (width === 0 || height === 0) {
|
|
54
|
-
continueRender(handle);
|
|
55
93
|
instance.clear();
|
|
94
|
+
clearOutput();
|
|
95
|
+
continueRender(handle);
|
|
56
96
|
return;
|
|
57
97
|
}
|
|
58
|
-
|
|
59
|
-
|
|
98
|
+
shaderCanvas.width = width;
|
|
99
|
+
shaderCanvas.height = height;
|
|
60
100
|
instance.draw({
|
|
61
101
|
prevImage,
|
|
62
102
|
nextImage,
|
|
@@ -67,14 +107,14 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
67
107
|
});
|
|
68
108
|
await remotion_1.Internals.runEffectChain({
|
|
69
109
|
state: chainState.get(width, height),
|
|
70
|
-
source:
|
|
110
|
+
source: shaderCanvas,
|
|
71
111
|
effects: (_e = effectsRef.current) !== null && _e !== void 0 ? _e : [],
|
|
72
112
|
width,
|
|
73
113
|
height,
|
|
74
|
-
output:
|
|
114
|
+
output: outputCanvas,
|
|
75
115
|
});
|
|
76
116
|
continueRender(handle);
|
|
77
|
-
}, [chainState,
|
|
117
|
+
}, [chainState, continueRender, delayRender, instance, shaderCanvas]);
|
|
78
118
|
const passThrough = bothEnteringAndExiting && presentationDirection === 'exiting';
|
|
79
119
|
(0, react_1.useLayoutEffect)(() => {
|
|
80
120
|
if (passThrough) {
|
|
@@ -87,11 +127,20 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
87
127
|
canvas.layoutSubtree = true;
|
|
88
128
|
const onPaint = () => {
|
|
89
129
|
const firstChild = canvas.firstChild;
|
|
90
|
-
|
|
130
|
+
const captureCanvas = captureCanvasRef.current;
|
|
131
|
+
const captureContext = captureContextRef.current;
|
|
132
|
+
if (!firstChild || !captureCanvas || !captureContext) {
|
|
91
133
|
return;
|
|
92
134
|
}
|
|
93
135
|
const elementImage = canvas.captureElementImage(firstChild);
|
|
94
|
-
|
|
136
|
+
try {
|
|
137
|
+
captureContext.reset();
|
|
138
|
+
captureContext.drawElementImage(elementImage, 0, 0);
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
elementImage.close();
|
|
142
|
+
}
|
|
143
|
+
onElementImage(captureCanvas, draw);
|
|
95
144
|
};
|
|
96
145
|
canvas.addEventListener('paint', onPaint);
|
|
97
146
|
return () => {
|
|
@@ -127,15 +176,31 @@ const HtmlInCanvasPresentation = ({ children, onElementImage, onUnmount, present
|
|
|
127
176
|
}
|
|
128
177
|
// Size the canvas grid to match the device scale factor to prevent blurriness.
|
|
129
178
|
const observer = new ResizeObserver(([entry]) => {
|
|
130
|
-
|
|
131
|
-
|
|
179
|
+
var _a;
|
|
180
|
+
const outputCanvas = outputCanvasRef.current;
|
|
181
|
+
const captureCanvas = captureCanvasRef.current;
|
|
182
|
+
if (!outputCanvas || !captureCanvas) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const width = entry.devicePixelContentBoxSize[0].inlineSize;
|
|
186
|
+
const height = entry.devicePixelContentBoxSize[0].blockSize;
|
|
187
|
+
captureCanvas.width = width;
|
|
188
|
+
captureCanvas.height = height;
|
|
189
|
+
outputCanvas.width = width;
|
|
190
|
+
outputCanvas.height = height;
|
|
191
|
+
(_a = canvas.requestPaint) === null || _a === void 0 ? void 0 : _a.call(canvas);
|
|
132
192
|
});
|
|
133
193
|
observer.observe(canvas, { box: 'device-pixel-content-box' });
|
|
194
|
+
return () => {
|
|
195
|
+
observer.disconnect();
|
|
196
|
+
};
|
|
134
197
|
}, [passThrough]);
|
|
135
198
|
if (passThrough) {
|
|
136
199
|
return children;
|
|
137
200
|
}
|
|
138
|
-
return (jsx_runtime_1.
|
|
201
|
+
return (jsx_runtime_1.jsxs(remotion_1.AbsoluteFill, { children: [
|
|
202
|
+
jsx_runtime_1.jsx("canvas", { ref: canvasRef, style: canvasSubtreeStyle, children: children }), jsx_runtime_1.jsx("canvas", { ref: outputCanvasRef, style: outputCanvasStyle })
|
|
203
|
+
] }));
|
|
139
204
|
};
|
|
140
205
|
exports.HtmlInCanvasPresentation = HtmlInCanvasPresentation;
|
|
141
206
|
const makeHtmlInCanvasPresentation = (shader) => {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bookFlip = exports.bookFlipShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const DIRECTION_FROM_LEFT = 0;
|
|
6
7
|
const DIRECTION_FROM_RIGHT = 1;
|
|
7
8
|
const DIRECTION_FROM_TOP = 2;
|
|
@@ -232,13 +233,13 @@ const bookFlipShader = (canvas) => {
|
|
|
232
233
|
gl.activeTexture(gl.TEXTURE0);
|
|
233
234
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
234
235
|
if (prevImage) {
|
|
235
|
-
|
|
236
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
236
237
|
}
|
|
237
238
|
gl.uniform1i(uPrev, 0);
|
|
238
239
|
gl.activeTexture(gl.TEXTURE1);
|
|
239
240
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
240
241
|
if (nextImage) {
|
|
241
|
-
|
|
242
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
242
243
|
}
|
|
243
244
|
gl.uniform1i(uNext, 1);
|
|
244
245
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.crossZoom = exports.crossZoomShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const DEFAULT_STRENGTH = 0.4;
|
|
6
7
|
const VERTEX_SHADER = `#version 300 es
|
|
7
8
|
in vec2 a_pos;
|
|
@@ -176,13 +177,13 @@ const crossZoomShader = (canvas) => {
|
|
|
176
177
|
gl.activeTexture(gl.TEXTURE0);
|
|
177
178
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
178
179
|
if (prevImage) {
|
|
179
|
-
|
|
180
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
180
181
|
}
|
|
181
182
|
gl.uniform1i(uPrev, 0);
|
|
182
183
|
gl.activeTexture(gl.TEXTURE1);
|
|
183
184
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
184
185
|
if (nextImage) {
|
|
185
|
-
|
|
186
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
186
187
|
}
|
|
187
188
|
gl.uniform1i(uNext, 1);
|
|
188
189
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.crosswarp = exports.crosswarpShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const VERTEX_SHADER = `#version 300 es
|
|
6
7
|
in vec2 a_pos;
|
|
7
8
|
out vec2 v_uv;
|
|
@@ -132,13 +133,13 @@ const crosswarpShader = (canvas) => {
|
|
|
132
133
|
gl.activeTexture(gl.TEXTURE0);
|
|
133
134
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
134
135
|
if (prevImage) {
|
|
135
|
-
|
|
136
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
136
137
|
}
|
|
137
138
|
gl.uniform1i(uPrev, 0);
|
|
138
139
|
gl.activeTexture(gl.TEXTURE1);
|
|
139
140
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
140
141
|
if (nextImage) {
|
|
141
|
-
|
|
142
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
142
143
|
}
|
|
143
144
|
gl.uniform1i(uNext, 1);
|
|
144
145
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dissolve = exports.dissolveShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const DEFAULT_LINE_WIDTH = 0.1;
|
|
6
7
|
const DEFAULT_SPREAD_COLOR = '#ff0000';
|
|
7
8
|
const DEFAULT_HOT_COLOR = '#e6e633';
|
|
@@ -164,13 +165,13 @@ const dissolveShader = (canvas) => {
|
|
|
164
165
|
gl.activeTexture(gl.TEXTURE0);
|
|
165
166
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
166
167
|
if (prevImage) {
|
|
167
|
-
|
|
168
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
168
169
|
}
|
|
169
170
|
gl.uniform1i(uPrev, 0);
|
|
170
171
|
gl.activeTexture(gl.TEXTURE1);
|
|
171
172
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
172
173
|
if (nextImage) {
|
|
173
|
-
|
|
174
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
174
175
|
}
|
|
175
176
|
gl.uniform1i(uNext, 1);
|
|
176
177
|
const spread = parseHexColor(spreadColor);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dreamyZoom = exports.dreamyZoomShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const DEFAULT_ROTATION = 6;
|
|
6
7
|
const DEFAULT_SCALE = 1.2;
|
|
7
8
|
const VERTEX_SHADER = `#version 300 es
|
|
@@ -144,13 +145,13 @@ const dreamyZoomShader = (canvas) => {
|
|
|
144
145
|
gl.activeTexture(gl.TEXTURE0);
|
|
145
146
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
146
147
|
if (prevImage) {
|
|
147
|
-
|
|
148
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
148
149
|
}
|
|
149
150
|
gl.uniform1i(uPrev, 0);
|
|
150
151
|
gl.activeTexture(gl.TEXTURE1);
|
|
151
152
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
152
153
|
if (nextImage) {
|
|
153
|
-
|
|
154
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
154
155
|
}
|
|
155
156
|
gl.uniform1i(uNext, 1);
|
|
156
157
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.filmBurn = exports.filmBurnShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const DEFAULT_SEED = 2.31;
|
|
6
7
|
const VERTEX_SHADER = `#version 300 es
|
|
7
8
|
in vec2 a_pos;
|
|
@@ -242,13 +243,13 @@ const filmBurnShader = (canvas) => {
|
|
|
242
243
|
gl.activeTexture(gl.TEXTURE0);
|
|
243
244
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
244
245
|
if (prevImage) {
|
|
245
|
-
|
|
246
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
246
247
|
}
|
|
247
248
|
gl.uniform1i(uPrev, 0);
|
|
248
249
|
gl.activeTexture(gl.TEXTURE1);
|
|
249
250
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
250
251
|
if (nextImage) {
|
|
251
|
-
|
|
252
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
252
253
|
}
|
|
253
254
|
gl.uniform1i(uNext, 1);
|
|
254
255
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.linearBlur = exports.linearBlurShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const VERTEX_SHADER = `#version 300 es
|
|
6
7
|
in vec2 a_pos;
|
|
7
8
|
out vec2 v_uv;
|
|
@@ -141,13 +142,13 @@ const linearBlurShader = (canvas) => {
|
|
|
141
142
|
gl.activeTexture(gl.TEXTURE0);
|
|
142
143
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
143
144
|
if (prevImage) {
|
|
144
|
-
|
|
145
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
145
146
|
}
|
|
146
147
|
gl.uniform1i(uPrev, 0);
|
|
147
148
|
gl.activeTexture(gl.TEXTURE1);
|
|
148
149
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
149
150
|
if (nextImage) {
|
|
150
|
-
|
|
151
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
151
152
|
}
|
|
152
153
|
gl.uniform1i(uNext, 1);
|
|
153
154
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ripple = exports.rippleShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const DEFAULT_AMPLITUDE = 100.0;
|
|
6
7
|
const DEFAULT_SPEED = 50.0;
|
|
7
8
|
const VERTEX_SHADER = `#version 300 es
|
|
@@ -140,13 +141,13 @@ const rippleShader = (canvas) => {
|
|
|
140
141
|
gl.activeTexture(gl.TEXTURE0);
|
|
141
142
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
142
143
|
if (prevImage) {
|
|
143
|
-
|
|
144
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
144
145
|
}
|
|
145
146
|
gl.uniform1i(uPrev, 0);
|
|
146
147
|
gl.activeTexture(gl.TEXTURE1);
|
|
147
148
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
148
149
|
if (nextImage) {
|
|
149
|
-
|
|
150
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
150
151
|
}
|
|
151
152
|
gl.uniform1i(uNext, 1);
|
|
152
153
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.swap = exports.swapShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const DEFAULT_REFLECTION = 0.4;
|
|
6
7
|
const DEFAULT_PERSPECTIVE = 0.2;
|
|
7
8
|
const DEFAULT_DEPTH = 3.0;
|
|
@@ -187,13 +188,13 @@ const swapShader = (canvas) => {
|
|
|
187
188
|
gl.activeTexture(gl.TEXTURE0);
|
|
188
189
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
189
190
|
if (prevImage) {
|
|
190
|
-
|
|
191
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
191
192
|
}
|
|
192
193
|
gl.uniform1i(uPrev, 0);
|
|
193
194
|
gl.activeTexture(gl.TEXTURE1);
|
|
194
195
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
195
196
|
if (nextImage) {
|
|
196
|
-
|
|
197
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
197
198
|
}
|
|
198
199
|
gl.uniform1i(uNext, 1);
|
|
199
200
|
gl.uniform1f(uTime, effectiveTime);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uploadElementImage: (gl: WebGL2RenderingContext, elementImage: OffscreenCanvas) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadElementImage = void 0;
|
|
4
|
+
const uploadElementImage = (gl, elementImage) => {
|
|
5
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, elementImage);
|
|
6
|
+
};
|
|
7
|
+
exports.uploadElementImage = uploadElementImage;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zoomBlur = exports.zoomBlurShader = void 0;
|
|
4
4
|
const html_in_canvas_presentation_1 = require("../html-in-canvas-presentation");
|
|
5
|
+
const upload_element_image_1 = require("./upload-element-image");
|
|
5
6
|
const VERTEX_SHADER = `#version 300 es
|
|
6
7
|
in vec2 a_pos;
|
|
7
8
|
out vec2 v_uv;
|
|
@@ -162,13 +163,13 @@ const zoomBlurShader = (canvas) => {
|
|
|
162
163
|
gl.activeTexture(gl.TEXTURE0);
|
|
163
164
|
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
164
165
|
if (prevImage) {
|
|
165
|
-
|
|
166
|
+
(0, upload_element_image_1.uploadElementImage)(gl, prevImage);
|
|
166
167
|
}
|
|
167
168
|
gl.uniform1i(uPrev, 0);
|
|
168
169
|
gl.activeTexture(gl.TEXTURE1);
|
|
169
170
|
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
170
171
|
if (nextImage) {
|
|
171
|
-
|
|
172
|
+
(0, upload_element_image_1.uploadElementImage)(gl, nextImage);
|
|
172
173
|
}
|
|
173
174
|
gl.uniform1i(uNext, 1);
|
|
174
175
|
gl.uniform1f(uTime, effectiveTime);
|