@smoove/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +80 -0
- package/dist/animation/color.d.ts +9 -0
- package/dist/animation/color.d.ts.map +1 -0
- package/dist/animation/color.js +224 -0
- package/dist/animation/color.js.map +1 -0
- package/dist/animation/easing.d.ts +22 -0
- package/dist/animation/easing.d.ts.map +1 -0
- package/dist/animation/easing.js +59 -0
- package/dist/animation/easing.js.map +1 -0
- package/dist/animation/interpolate-colors.d.ts +7 -0
- package/dist/animation/interpolate-colors.d.ts.map +1 -0
- package/dist/animation/interpolate-colors.js +19 -0
- package/dist/animation/interpolate-colors.js.map +1 -0
- package/dist/animation/interpolate.d.ts +12 -0
- package/dist/animation/interpolate.d.ts.map +1 -0
- package/dist/animation/interpolate.js +65 -0
- package/dist/animation/interpolate.js.map +1 -0
- package/dist/audio/asset.d.ts +21 -0
- package/dist/audio/asset.d.ts.map +1 -0
- package/dist/audio/asset.js +2 -0
- package/dist/audio/asset.js.map +1 -0
- package/dist/audio/audio-driver.d.ts +34 -0
- package/dist/audio/audio-driver.d.ts.map +1 -0
- package/dist/audio/audio-driver.js +2 -0
- package/dist/audio/audio-driver.js.map +1 -0
- package/dist/audio/audio-for-preview.d.ts +12 -0
- package/dist/audio/audio-for-preview.d.ts.map +1 -0
- package/dist/audio/audio-for-preview.js +70 -0
- package/dist/audio/audio-for-preview.js.map +1 -0
- package/dist/audio/audio-for-rendering.d.ts +16 -0
- package/dist/audio/audio-for-rendering.d.ts.map +1 -0
- package/dist/audio/audio-for-rendering.js +32 -0
- package/dist/audio/audio-for-rendering.js.map +1 -0
- package/dist/audio/audio-source-browser.d.ts +30 -0
- package/dist/audio/audio-source-browser.d.ts.map +1 -0
- package/dist/audio/audio-source-browser.js +139 -0
- package/dist/audio/audio-source-browser.js.map +1 -0
- package/dist/audio/audio-source.d.ts +38 -0
- package/dist/audio/audio-source.d.ts.map +1 -0
- package/dist/audio/audio-source.js +2 -0
- package/dist/audio/audio-source.js.map +1 -0
- package/dist/audio/index.d.ts +45 -0
- package/dist/audio/index.d.ts.map +1 -0
- package/dist/audio/index.js +143 -0
- package/dist/audio/index.js.map +1 -0
- package/dist/audio/mixer.d.ts +43 -0
- package/dist/audio/mixer.d.ts.map +1 -0
- package/dist/audio/mixer.js +51 -0
- package/dist/audio/mixer.js.map +1 -0
- package/dist/audio/types.d.ts +31 -0
- package/dist/audio/types.d.ts.map +1 -0
- package/dist/audio/types.js +2 -0
- package/dist/audio/types.js.map +1 -0
- package/dist/block.d.ts +16 -0
- package/dist/block.d.ts.map +1 -0
- package/dist/block.js +173 -0
- package/dist/block.js.map +1 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js.map +1 -0
- package/dist/easing.d.ts +22 -0
- package/dist/easing.d.ts.map +1 -0
- package/dist/easing.js +59 -0
- package/dist/easing.js.map +1 -0
- package/dist/emitter.d.ts +7 -0
- package/dist/emitter.d.ts.map +1 -0
- package/dist/emitter.js +29 -0
- package/dist/emitter.js.map +1 -0
- package/dist/engine/composition.d.ts +182 -0
- package/dist/engine/composition.d.ts.map +1 -0
- package/dist/engine/composition.js +527 -0
- package/dist/engine/composition.js.map +1 -0
- package/dist/engine/emitter.d.ts +7 -0
- package/dist/engine/emitter.d.ts.map +1 -0
- package/dist/engine/emitter.js +29 -0
- package/dist/engine/emitter.js.map +1 -0
- package/dist/engine/environment.d.ts +30 -0
- package/dist/engine/environment.d.ts.map +1 -0
- package/dist/engine/environment.js +27 -0
- package/dist/engine/environment.js.map +1 -0
- package/dist/engine/offsets.d.ts +39 -0
- package/dist/engine/offsets.d.ts.map +1 -0
- package/dist/engine/offsets.js +54 -0
- package/dist/engine/offsets.js.map +1 -0
- package/dist/engine/runtime-defaults.d.ts +50 -0
- package/dist/engine/runtime-defaults.d.ts.map +1 -0
- package/dist/engine/runtime-defaults.js +77 -0
- package/dist/engine/runtime-defaults.js.map +1 -0
- package/dist/engine/sequence.d.ts +44 -0
- package/dist/engine/sequence.d.ts.map +1 -0
- package/dist/engine/sequence.js +101 -0
- package/dist/engine/sequence.js.map +1 -0
- package/dist/engine/series.d.ts +40 -0
- package/dist/engine/series.d.ts.map +1 -0
- package/dist/engine/series.js +58 -0
- package/dist/engine/series.js.map +1 -0
- package/dist/engine/signal.d.ts +10 -0
- package/dist/engine/signal.d.ts.map +1 -0
- package/dist/engine/signal.js +39 -0
- package/dist/engine/signal.js.map +1 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js.map +1 -0
- package/dist/flex-engine.d.ts +31 -0
- package/dist/flex-engine.d.ts.map +1 -0
- package/dist/flex-engine.js +186 -0
- package/dist/flex-engine.js.map +1 -0
- package/dist/flex-types.d.ts +165 -0
- package/dist/flex-types.d.ts.map +1 -0
- package/dist/flex-types.js +2 -0
- package/dist/flex-types.js.map +1 -0
- package/dist/flex.d.ts +26 -0
- package/dist/flex.d.ts.map +1 -0
- package/dist/flex.js +179 -0
- package/dist/flex.js.map +1 -0
- package/dist/image.d.ts +10 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/image.js +156 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/interpolate-colors.d.ts +7 -0
- package/dist/interpolate-colors.d.ts.map +1 -0
- package/dist/interpolate-colors.js +240 -0
- package/dist/interpolate-colors.js.map +1 -0
- package/dist/interpolate.d.ts +12 -0
- package/dist/interpolate.d.ts.map +1 -0
- package/dist/interpolate.js +65 -0
- package/dist/interpolate.js.map +1 -0
- package/dist/layout/block.d.ts +54 -0
- package/dist/layout/block.d.ts.map +1 -0
- package/dist/layout/block.js +186 -0
- package/dist/layout/block.js.map +1 -0
- package/dist/layout/contract.d.ts +41 -0
- package/dist/layout/contract.d.ts.map +1 -0
- package/dist/layout/contract.js +8 -0
- package/dist/layout/contract.js.map +1 -0
- package/dist/layout/flex/engine.d.ts +31 -0
- package/dist/layout/flex/engine.d.ts.map +1 -0
- package/dist/layout/flex/engine.js +186 -0
- package/dist/layout/flex/engine.js.map +1 -0
- package/dist/layout/flex/flex.d.ts +31 -0
- package/dist/layout/flex/flex.d.ts.map +1 -0
- package/dist/layout/flex/flex.js +175 -0
- package/dist/layout/flex/flex.js.map +1 -0
- package/dist/layout/flex/mixin.d.ts +52 -0
- package/dist/layout/flex/mixin.d.ts.map +1 -0
- package/dist/layout/flex/mixin.js +114 -0
- package/dist/layout/flex/mixin.js.map +1 -0
- package/dist/layout/flex/types.d.ts +31 -0
- package/dist/layout/flex/types.d.ts.map +1 -0
- package/dist/layout/flex/types.js +2 -0
- package/dist/layout/flex/types.js.map +1 -0
- package/dist/layout/image.d.ts +46 -0
- package/dist/layout/image.d.ts.map +1 -0
- package/dist/layout/image.js +198 -0
- package/dist/layout/image.js.map +1 -0
- package/dist/layout/shapes.d.ts +72 -0
- package/dist/layout/shapes.d.ts.map +1 -0
- package/dist/layout/shapes.js +29 -0
- package/dist/layout/shapes.js.map +1 -0
- package/dist/layout/text/font.d.ts +92 -0
- package/dist/layout/text/font.d.ts.map +1 -0
- package/dist/layout/text/font.js +166 -0
- package/dist/layout/text/font.js.map +1 -0
- package/dist/layout/text/geometry.d.ts +31 -0
- package/dist/layout/text/geometry.d.ts.map +1 -0
- package/dist/layout/text/geometry.js +81 -0
- package/dist/layout/text/geometry.js.map +1 -0
- package/dist/layout/text/text.d.ts +98 -0
- package/dist/layout/text/text.d.ts.map +1 -0
- package/dist/layout/text/text.js +676 -0
- package/dist/layout/text/text.js.map +1 -0
- package/dist/layout/text/types.d.ts +103 -0
- package/dist/layout/text/types.d.ts.map +1 -0
- package/dist/layout/text/types.js +2 -0
- package/dist/layout/text/types.js.map +1 -0
- package/dist/media/audio/asset.d.ts +21 -0
- package/dist/media/audio/asset.d.ts.map +1 -0
- package/dist/media/audio/asset.js +2 -0
- package/dist/media/audio/asset.js.map +1 -0
- package/dist/media/audio/audio-driver.d.ts +34 -0
- package/dist/media/audio/audio-driver.d.ts.map +1 -0
- package/dist/media/audio/audio-driver.js +2 -0
- package/dist/media/audio/audio-driver.js.map +1 -0
- package/dist/media/audio/audio-for-preview.d.ts +47 -0
- package/dist/media/audio/audio-for-preview.d.ts.map +1 -0
- package/dist/media/audio/audio-for-preview.js +232 -0
- package/dist/media/audio/audio-for-preview.js.map +1 -0
- package/dist/media/audio/audio-for-rendering.d.ts +16 -0
- package/dist/media/audio/audio-for-rendering.d.ts.map +1 -0
- package/dist/media/audio/audio-for-rendering.js +32 -0
- package/dist/media/audio/audio-for-rendering.js.map +1 -0
- package/dist/media/audio/audio-source-browser.d.ts +30 -0
- package/dist/media/audio/audio-source-browser.d.ts.map +1 -0
- package/dist/media/audio/audio-source-browser.js +139 -0
- package/dist/media/audio/audio-source-browser.js.map +1 -0
- package/dist/media/audio/audio-source-mediabunny.d.ts +45 -0
- package/dist/media/audio/audio-source-mediabunny.d.ts.map +1 -0
- package/dist/media/audio/audio-source-mediabunny.js +79 -0
- package/dist/media/audio/audio-source-mediabunny.js.map +1 -0
- package/dist/media/audio/audio-source.d.ts +38 -0
- package/dist/media/audio/audio-source.d.ts.map +1 -0
- package/dist/media/audio/audio-source.js +2 -0
- package/dist/media/audio/audio-source.js.map +1 -0
- package/dist/media/audio/index.d.ts +57 -0
- package/dist/media/audio/index.d.ts.map +1 -0
- package/dist/media/audio/index.js +170 -0
- package/dist/media/audio/index.js.map +1 -0
- package/dist/media/audio/mixer.d.ts +43 -0
- package/dist/media/audio/mixer.d.ts.map +1 -0
- package/dist/media/audio/mixer.js +51 -0
- package/dist/media/audio/mixer.js.map +1 -0
- package/dist/media/audio/shared-audio-context.d.ts +30 -0
- package/dist/media/audio/shared-audio-context.d.ts.map +1 -0
- package/dist/media/audio/shared-audio-context.js +68 -0
- package/dist/media/audio/shared-audio-context.js.map +1 -0
- package/dist/media/audio/types.d.ts +31 -0
- package/dist/media/audio/types.d.ts.map +1 -0
- package/dist/media/audio/types.js +2 -0
- package/dist/media/audio/types.js.map +1 -0
- package/dist/media/media-marker.d.ts +26 -0
- package/dist/media/media-marker.d.ts.map +1 -0
- package/dist/media/media-marker.js +26 -0
- package/dist/media/media-marker.js.map +1 -0
- package/dist/media/media-time.d.ts +17 -0
- package/dist/media/media-time.d.ts.map +1 -0
- package/dist/media/media-time.js +17 -0
- package/dist/media/media-time.js.map +1 -0
- package/dist/media/video/driver.d.ts +31 -0
- package/dist/media/video/driver.d.ts.map +1 -0
- package/dist/media/video/driver.js +3 -0
- package/dist/media/video/driver.js.map +1 -0
- package/dist/media/video/index.d.ts +66 -0
- package/dist/media/video/index.d.ts.map +1 -0
- package/dist/media/video/index.js +372 -0
- package/dist/media/video/index.js.map +1 -0
- package/dist/media/video/types.d.ts +36 -0
- package/dist/media/video/types.d.ts.map +1 -0
- package/dist/media/video/types.js +2 -0
- package/dist/media/video/types.js.map +1 -0
- package/dist/media/video/video-for-preview.d.ts +17 -0
- package/dist/media/video/video-for-preview.d.ts.map +1 -0
- package/dist/media/video/video-for-preview.js +30 -0
- package/dist/media/video/video-for-preview.js.map +1 -0
- package/dist/media/video/video-for-rendering.d.ts +17 -0
- package/dist/media/video/video-for-rendering.d.ts.map +1 -0
- package/dist/media/video/video-for-rendering.js +59 -0
- package/dist/media/video/video-for-rendering.js.map +1 -0
- package/dist/media/video/video-source-browser.d.ts +37 -0
- package/dist/media/video/video-source-browser.d.ts.map +1 -0
- package/dist/media/video/video-source-browser.js +171 -0
- package/dist/media/video/video-source-browser.js.map +1 -0
- package/dist/media/video/video-source-mediabunny.d.ts +69 -0
- package/dist/media/video/video-source-mediabunny.d.ts.map +1 -0
- package/dist/media/video/video-source-mediabunny.js +236 -0
- package/dist/media/video/video-source-mediabunny.js.map +1 -0
- package/dist/media/video/video-source.d.ts +48 -0
- package/dist/media/video/video-source.d.ts.map +1 -0
- package/dist/media/video/video-source.js +2 -0
- package/dist/media/video/video-source.js.map +1 -0
- package/dist/media-marker.d.ts +19 -0
- package/dist/media-marker.d.ts.map +1 -0
- package/dist/media-marker.js +19 -0
- package/dist/media-marker.js.map +1 -0
- package/dist/media-time.d.ts +17 -0
- package/dist/media-time.d.ts.map +1 -0
- package/dist/media-time.js +17 -0
- package/dist/media-time.js.map +1 -0
- package/dist/signal.d.ts +10 -0
- package/dist/signal.d.ts.map +1 -0
- package/dist/signal.js +39 -0
- package/dist/signal.js.map +1 -0
- package/dist/text.d.ts +91 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +704 -0
- package/dist/text.js.map +1 -0
- package/dist/video/driver.d.ts +31 -0
- package/dist/video/driver.d.ts.map +1 -0
- package/dist/video/driver.js +3 -0
- package/dist/video/driver.js.map +1 -0
- package/dist/video/index.d.ts +45 -0
- package/dist/video/index.d.ts.map +1 -0
- package/dist/video/index.js +276 -0
- package/dist/video/index.js.map +1 -0
- package/dist/video/types.d.ts +35 -0
- package/dist/video/types.d.ts.map +1 -0
- package/dist/video/types.js +2 -0
- package/dist/video/types.js.map +1 -0
- package/dist/video/video-for-preview.d.ts +12 -0
- package/dist/video/video-for-preview.d.ts.map +1 -0
- package/dist/video/video-for-preview.js +73 -0
- package/dist/video/video-for-preview.js.map +1 -0
- package/dist/video/video-for-rendering.d.ts +16 -0
- package/dist/video/video-for-rendering.d.ts.map +1 -0
- package/dist/video/video-for-rendering.js +45 -0
- package/dist/video/video-for-rendering.js.map +1 -0
- package/dist/video/video-source-browser.d.ts +37 -0
- package/dist/video/video-source-browser.d.ts.map +1 -0
- package/dist/video/video-source-browser.js +171 -0
- package/dist/video/video-source-browser.js.map +1 -0
- package/dist/video/video-source.d.ts +48 -0
- package/dist/video/video-source.d.ts.map +1 -0
- package/dist/video/video-source.js +2 -0
- package/dist/video/video-source.js.map +1 -0
- package/package.json +42 -0
package/dist/image.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import Konva from "konva";
|
|
2
|
+
import { parseSize } from "./flex-engine.js";
|
|
3
|
+
const IMG_KEYS = [
|
|
4
|
+
"src",
|
|
5
|
+
"objectFit",
|
|
6
|
+
"objectPosition",
|
|
7
|
+
"flexGrow",
|
|
8
|
+
"flexShrink",
|
|
9
|
+
"flexBasis",
|
|
10
|
+
"alignSelf",
|
|
11
|
+
"margin",
|
|
12
|
+
];
|
|
13
|
+
function pickKonvaConfig(config) {
|
|
14
|
+
const out = { ...config };
|
|
15
|
+
for (const k of IMG_KEYS)
|
|
16
|
+
delete out[k];
|
|
17
|
+
const w = parseSize(config.width);
|
|
18
|
+
const h = parseSize(config.height);
|
|
19
|
+
out.width = w?.kind === "px" ? w.value : undefined;
|
|
20
|
+
out.height = h?.kind === "px" ? h.value : undefined;
|
|
21
|
+
out.cornerRadius = undefined;
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
function loadImage(src) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const img = document.createElement("img");
|
|
27
|
+
img.crossOrigin = "anonymous";
|
|
28
|
+
img.onload = () => resolve(img);
|
|
29
|
+
img.onerror = reject;
|
|
30
|
+
img.src = src;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export class Image extends Konva.Group {
|
|
34
|
+
_img;
|
|
35
|
+
_source = null;
|
|
36
|
+
constructor(config) {
|
|
37
|
+
super(pickKonvaConfig(config));
|
|
38
|
+
this._img = new Konva.Image({ image: undefined, listening: false });
|
|
39
|
+
super.add(this._img);
|
|
40
|
+
this.setAttrs({
|
|
41
|
+
flexGrow: config.flexGrow,
|
|
42
|
+
flexShrink: config.flexShrink,
|
|
43
|
+
flexBasis: config.flexBasis,
|
|
44
|
+
alignSelf: config.alignSelf,
|
|
45
|
+
margin: config.margin,
|
|
46
|
+
objectFit: config.objectFit ?? "cover",
|
|
47
|
+
objectPosition: config.objectPosition ?? "center",
|
|
48
|
+
cornerRadius: config.cornerRadius,
|
|
49
|
+
flexWidth: config.width,
|
|
50
|
+
flexHeight: config.height,
|
|
51
|
+
});
|
|
52
|
+
if (config.cornerRadius !== undefined) {
|
|
53
|
+
const cr = normalizeCorners(config.cornerRadius);
|
|
54
|
+
this.clipFunc((ctx) => roundRectPath(ctx, 0, 0, this.width(), this.height(), cr));
|
|
55
|
+
}
|
|
56
|
+
this.on("widthChange heightChange", () => this._layoutImage());
|
|
57
|
+
if (typeof config.src === "string") {
|
|
58
|
+
loadImage(config.src).then((img) => {
|
|
59
|
+
this._source = img;
|
|
60
|
+
this._img.image(img);
|
|
61
|
+
this._layoutImage();
|
|
62
|
+
this.getLayer()?.batchDraw();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this._source = config.src;
|
|
67
|
+
this._img.image(config.src);
|
|
68
|
+
}
|
|
69
|
+
this._layoutImage();
|
|
70
|
+
}
|
|
71
|
+
/** @internal */
|
|
72
|
+
_layoutImage() {
|
|
73
|
+
const w = this.width();
|
|
74
|
+
const h = this.height();
|
|
75
|
+
if (w <= 0 || h <= 0)
|
|
76
|
+
return;
|
|
77
|
+
const src = this._source;
|
|
78
|
+
const fit = (this.attrs.objectFit ?? "cover");
|
|
79
|
+
const pos = (this.attrs.objectPosition ?? "center");
|
|
80
|
+
if (!src || src.naturalWidth === 0 || src.naturalHeight === 0)
|
|
81
|
+
return;
|
|
82
|
+
const nw = src.naturalWidth;
|
|
83
|
+
const nh = src.naturalHeight;
|
|
84
|
+
if (fit === "fill") {
|
|
85
|
+
this._img.position({ x: 0, y: 0 });
|
|
86
|
+
this._img.size({ width: w, height: h });
|
|
87
|
+
this._img.crop({ x: 0, y: 0, width: nw, height: nh });
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (fit === "none") {
|
|
91
|
+
const { x, y } = positionOffset(pos, w - nw, h - nh);
|
|
92
|
+
this._img.position({ x, y });
|
|
93
|
+
this._img.size({ width: nw, height: nh });
|
|
94
|
+
this._img.crop({ x: 0, y: 0, width: nw, height: nh });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (fit === "contain") {
|
|
98
|
+
const scale = Math.min(w / nw, h / nh);
|
|
99
|
+
const dw = nw * scale;
|
|
100
|
+
const dh = nh * scale;
|
|
101
|
+
const { x, y } = positionOffset(pos, w - dw, h - dh);
|
|
102
|
+
this._img.position({ x, y });
|
|
103
|
+
this._img.size({ width: dw, height: dh });
|
|
104
|
+
this._img.crop({ x: 0, y: 0, width: nw, height: nh });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const scale = Math.max(w / nw, h / nh);
|
|
108
|
+
const cropW = w / scale;
|
|
109
|
+
const cropH = h / scale;
|
|
110
|
+
const { x: cx, y: cy } = positionOffset(pos, nw - cropW, nh - cropH);
|
|
111
|
+
this._img.position({ x: 0, y: 0 });
|
|
112
|
+
this._img.size({ width: w, height: h });
|
|
113
|
+
this._img.crop({ x: cx, y: cy, width: cropW, height: cropH });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function positionOffset(pos, freeX, freeY) {
|
|
117
|
+
let fx = 0.5;
|
|
118
|
+
let fy = 0.5;
|
|
119
|
+
if (pos.includes("left"))
|
|
120
|
+
fx = 0;
|
|
121
|
+
else if (pos.includes("right"))
|
|
122
|
+
fx = 1;
|
|
123
|
+
if (pos.includes("top"))
|
|
124
|
+
fy = 0;
|
|
125
|
+
else if (pos.includes("bottom"))
|
|
126
|
+
fy = 1;
|
|
127
|
+
if (pos === "center") {
|
|
128
|
+
fx = 0.5;
|
|
129
|
+
fy = 0.5;
|
|
130
|
+
}
|
|
131
|
+
return { x: freeX * fx, y: freeY * fy };
|
|
132
|
+
}
|
|
133
|
+
function normalizeCorners(c) {
|
|
134
|
+
if (typeof c === "number")
|
|
135
|
+
return [c, c, c, c];
|
|
136
|
+
if (c.length === 1)
|
|
137
|
+
return [c[0] ?? 0, c[0] ?? 0, c[0] ?? 0, c[0] ?? 0];
|
|
138
|
+
if (c.length === 2)
|
|
139
|
+
return [c[0] ?? 0, c[1] ?? 0, c[0] ?? 0, c[1] ?? 0];
|
|
140
|
+
return [c[0] ?? 0, c[1] ?? 0, c[2] ?? 0, c[3] ?? 0];
|
|
141
|
+
}
|
|
142
|
+
function roundRectPath(ctx, x, y, w, h, r) {
|
|
143
|
+
const [tl, tr, br, bl] = r;
|
|
144
|
+
ctx.beginPath();
|
|
145
|
+
ctx.moveTo(x + (tl ?? 0), y);
|
|
146
|
+
ctx.lineTo(x + w - (tr ?? 0), y);
|
|
147
|
+
ctx.quadraticCurveTo(x + w, y, x + w, y + (tr ?? 0));
|
|
148
|
+
ctx.lineTo(x + w, y + h - (br ?? 0));
|
|
149
|
+
ctx.quadraticCurveTo(x + w, y + h, x + w - (br ?? 0), y + h);
|
|
150
|
+
ctx.lineTo(x + (bl ?? 0), y + h);
|
|
151
|
+
ctx.quadraticCurveTo(x, y + h, x, y + h - (bl ?? 0));
|
|
152
|
+
ctx.lineTo(x, y + (tl ?? 0));
|
|
153
|
+
ctx.quadraticCurveTo(x, y, x + (tl ?? 0), y);
|
|
154
|
+
ctx.closePath();
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,MAAM,QAAQ,GAAG;IACf,KAAK;IACL,WAAW;IACX,gBAAgB;IAChB,UAAU;IACV,YAAY;IACZ,WAAW;IACX,WAAW;IACX,QAAQ;CACA,CAAC;AAEX,SAAS,eAAe,CAAC,MAAmB;IAC1C,MAAM,GAAG,GAA4B,EAAE,GAAG,MAAM,EAAE,CAAC;IACnD,KAAK,MAAM,CAAC,IAAI,QAAQ;QAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,KAA8B,CAAC,CAAC;IAC3D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export { Easing } from "./animation/easing.js";
|
|
2
|
+
export { type ExtrapolateType, type InterpolateOptions, interpolate, } from "./animation/interpolate.js";
|
|
3
|
+
export { interpolateColors } from "./animation/interpolate-colors.js";
|
|
4
|
+
export { type BufferState, Composition, type CompositionEvent, type CompositionEventMap, type CompositionEventName, type CompositionOptions, getComposition, } from "./engine/composition.js";
|
|
5
|
+
export { detectEnvironment, type Environment, type EnvironmentMode, getEnvironment, } from "./engine/environment.js";
|
|
6
|
+
export { type ComputeOffsetsResult, computeOffsets, type OffsetScene, type PlacedScene, } from "./engine/offsets.js";
|
|
7
|
+
export { type FontFaceDescriptor, type FontLoader, getDefaultAudioSourceFactory, getDefaultFontLoader, getDefaultImageLoader, getDefaultVideoSourceFactory, type ImageLoader, type LoadedImage, loadFontFace, setDefaultAudioSourceFactory, setDefaultFontLoader, setDefaultImageLoader, setDefaultVideoSourceFactory, } from "./engine/runtime-defaults.js";
|
|
8
|
+
export { Sequence, type SequenceOptions, type SequenceProvider, type Updater, } from "./engine/sequence.js";
|
|
9
|
+
export { Series, type SeriesOptions, type SeriesSceneOptions, } from "./engine/series.js";
|
|
10
|
+
export type { ReadonlySignal } from "./engine/signal.js";
|
|
11
|
+
export { type BackgroundValue, Block, type BlockConfig, type EdgeColor, type GradientBackground, type GradientStop, type ShadowProps, } from "./layout/block.js";
|
|
12
|
+
export { isKMLayoutNode, isKMLayoutRoot, type KMLayoutNode, type LayoutBox, type MeasureContext, } from "./layout/contract.js";
|
|
13
|
+
export { Flex } from "./layout/flex/flex.js";
|
|
14
|
+
export { FlexShape, type LeafConfig } from "./layout/flex/mixin.js";
|
|
15
|
+
export type { Align, AlignSelf, EdgeValue, FlexChildProps, FlexConfig, FlexDirection, FlexProps, Justify, SizeValue, } from "./layout/flex/types.js";
|
|
16
|
+
export { Image, type ImageConfig, type ObjectFit, type ObjectPosition, } from "./layout/image.js";
|
|
17
|
+
export { Arc, type ArcConfig, Arrow, type ArrowConfig, Circle, type CircleConfig, Ellipse, type EllipseConfig, Line, type LineConfig, Path, type PathConfig, Rect, type RectConfig, RegularPolygon, type RegularPolygonConfig, Ring, type RingConfig, Sprite, type SpriteConfig, Star, type StarConfig, TextPath, type TextPathConfig, Wedge, type WedgeConfig, } from "./layout/shapes.js";
|
|
18
|
+
export { Font, type FontConfig, type FontFace, type FontFaceRef, type FontStyleName, } from "./layout/text/font.js";
|
|
19
|
+
export { Text } from "./layout/text/text.js";
|
|
20
|
+
export type { FitConfig, HighlightConfig, TextAlign, TextConfig, TypewriterConfig, } from "./layout/text/types.js";
|
|
21
|
+
export type { AudioAsset } from "./media/audio/asset.js";
|
|
22
|
+
export type { AudioSource, AudioSourceFactory } from "./media/audio/audio-source.js";
|
|
23
|
+
export { BrowserAudioSource } from "./media/audio/audio-source-browser.js";
|
|
24
|
+
export { MediabunnyAudioSource, type SchedulableAudioSource, } from "./media/audio/audio-source-mediabunny.js";
|
|
25
|
+
export { Audio, isAudioNode } from "./media/audio/index.js";
|
|
26
|
+
export { type AudioChannel, AudioMixer } from "./media/audio/mixer.js";
|
|
27
|
+
export type { AudioConfig } from "./media/audio/types.js";
|
|
28
|
+
export { getMediaTime, type MediaTiming } from "./media/media-time.js";
|
|
29
|
+
export { isVideoNode, Video } from "./media/video/index.js";
|
|
30
|
+
export type { VideoConfig } from "./media/video/types.js";
|
|
31
|
+
export type { VideoSource, VideoSourceFactory } from "./media/video/video-source.js";
|
|
32
|
+
export { BrowserVideoSource } from "./media/video/video-source-browser.js";
|
|
33
|
+
export { MediabunnyVideoSource } from "./media/video/video-source-mediabunny.js";
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,WAAW,GACZ,MAAM,4BAA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,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { Easing } from "./animation/easing.js";
|
|
2
|
+
export { interpolate, } from "./animation/interpolate.js";
|
|
3
|
+
export { interpolateColors } from "./animation/interpolate-colors.js";
|
|
4
|
+
export { Composition, getComposition, } from "./engine/composition.js";
|
|
5
|
+
export { detectEnvironment, getEnvironment, } from "./engine/environment.js";
|
|
6
|
+
export {
|
|
7
|
+
// @internal — offset engine reused by @smoove/transitions.
|
|
8
|
+
computeOffsets, } from "./engine/offsets.js";
|
|
9
|
+
export { getDefaultAudioSourceFactory, getDefaultFontLoader, getDefaultImageLoader, getDefaultVideoSourceFactory, loadFontFace, setDefaultAudioSourceFactory, setDefaultFontLoader, setDefaultImageLoader, setDefaultVideoSourceFactory, } from "./engine/runtime-defaults.js";
|
|
10
|
+
export { Sequence, } from "./engine/sequence.js";
|
|
11
|
+
export { Series, } from "./engine/series.js";
|
|
12
|
+
export { Block, } from "./layout/block.js";
|
|
13
|
+
export { isKMLayoutNode, isKMLayoutRoot, } from "./layout/contract.js";
|
|
14
|
+
export { Flex } from "./layout/flex/flex.js";
|
|
15
|
+
export { FlexShape } from "./layout/flex/mixin.js";
|
|
16
|
+
export { Image, } from "./layout/image.js";
|
|
17
|
+
export { Arc, Arrow, Circle, Ellipse, Line, Path, Rect, RegularPolygon, Ring, Sprite, Star, TextPath, Wedge, } from "./layout/shapes.js";
|
|
18
|
+
export { Font, } from "./layout/text/font.js";
|
|
19
|
+
export { Text } from "./layout/text/text.js";
|
|
20
|
+
export { BrowserAudioSource } from "./media/audio/audio-source-browser.js";
|
|
21
|
+
export { MediabunnyAudioSource, } from "./media/audio/audio-source-mediabunny.js";
|
|
22
|
+
export { Audio, isAudioNode } from "./media/audio/index.js";
|
|
23
|
+
export { AudioMixer } from "./media/audio/mixer.js";
|
|
24
|
+
export { getMediaTime } from "./media/media-time.js";
|
|
25
|
+
export { isVideoNode, Video } from "./media/video/index.js";
|
|
26
|
+
export { BrowserVideoSource } from "./media/video/video-source-browser.js";
|
|
27
|
+
export { MediabunnyVideoSource } from "./media/video/video-source-mediabunny.js";
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAGL,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAEL,WAAW,EAKX,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,EAGjB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO;AAEL,2DAA2D;AAC3D,cAAc,GAGf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,4BAA4B,EAG5B,YAAY,EACZ,4BAA4B,EAC5B,oBAAoB,EACpB,qBAA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list of colors. API-compatible with Remotion's
|
|
3
|
+
* `interpolateColors`. Returns an `rgba(r, g, b, a)` string. Extrapolation
|
|
4
|
+
* is clamped on both sides.
|
|
5
|
+
*/
|
|
6
|
+
export declare const interpolateColors: (input: number, inputRange: readonly number[], outputRange: readonly string[]) => string;
|
|
7
|
+
//# sourceMappingURL=interpolate-colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate-colors.d.ts","sourceRoot":"","sources":["../src/interpolate-colors.ts"],"names":[],"mappings":"AAwOA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,MAAM,EACb,YAAY,SAAS,MAAM,EAAE,EAC7B,aAAa,SAAS,MAAM,EAAE,KAC7B,MAuCF,CAAC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { interpolate } from "./interpolate.js";
|
|
2
|
+
// CSS named colors (CSS Color Module Level 4).
|
|
3
|
+
const NAMED_COLORS = {
|
|
4
|
+
aliceblue: "#f0f8ff",
|
|
5
|
+
antiquewhite: "#faebd7",
|
|
6
|
+
aqua: "#00ffff",
|
|
7
|
+
aquamarine: "#7fffd4",
|
|
8
|
+
azure: "#f0ffff",
|
|
9
|
+
beige: "#f5f5dc",
|
|
10
|
+
bisque: "#ffe4c4",
|
|
11
|
+
black: "#000000",
|
|
12
|
+
blanchedalmond: "#ffebcd",
|
|
13
|
+
blue: "#0000ff",
|
|
14
|
+
blueviolet: "#8a2be2",
|
|
15
|
+
brown: "#a52a2a",
|
|
16
|
+
burlywood: "#deb887",
|
|
17
|
+
cadetblue: "#5f9ea0",
|
|
18
|
+
chartreuse: "#7fff00",
|
|
19
|
+
chocolate: "#d2691e",
|
|
20
|
+
coral: "#ff7f50",
|
|
21
|
+
cornflowerblue: "#6495ed",
|
|
22
|
+
cornsilk: "#fff8dc",
|
|
23
|
+
crimson: "#dc143c",
|
|
24
|
+
cyan: "#00ffff",
|
|
25
|
+
darkblue: "#00008b",
|
|
26
|
+
darkcyan: "#008b8b",
|
|
27
|
+
darkgoldenrod: "#b8860b",
|
|
28
|
+
darkgray: "#a9a9a9",
|
|
29
|
+
darkgreen: "#006400",
|
|
30
|
+
darkgrey: "#a9a9a9",
|
|
31
|
+
darkkhaki: "#bdb76b",
|
|
32
|
+
darkmagenta: "#8b008b",
|
|
33
|
+
darkolivegreen: "#556b2f",
|
|
34
|
+
darkorange: "#ff8c00",
|
|
35
|
+
darkorchid: "#9932cc",
|
|
36
|
+
darkred: "#8b0000",
|
|
37
|
+
darksalmon: "#e9967a",
|
|
38
|
+
darkseagreen: "#8fbc8f",
|
|
39
|
+
darkslateblue: "#483d8b",
|
|
40
|
+
darkslategray: "#2f4f4f",
|
|
41
|
+
darkslategrey: "#2f4f4f",
|
|
42
|
+
darkturquoise: "#00ced1",
|
|
43
|
+
darkviolet: "#9400d3",
|
|
44
|
+
deeppink: "#ff1493",
|
|
45
|
+
deepskyblue: "#00bfff",
|
|
46
|
+
dimgray: "#696969",
|
|
47
|
+
dimgrey: "#696969",
|
|
48
|
+
dodgerblue: "#1e90ff",
|
|
49
|
+
firebrick: "#b22222",
|
|
50
|
+
floralwhite: "#fffaf0",
|
|
51
|
+
forestgreen: "#228b22",
|
|
52
|
+
fuchsia: "#ff00ff",
|
|
53
|
+
gainsboro: "#dcdcdc",
|
|
54
|
+
ghostwhite: "#f8f8ff",
|
|
55
|
+
gold: "#ffd700",
|
|
56
|
+
goldenrod: "#daa520",
|
|
57
|
+
gray: "#808080",
|
|
58
|
+
green: "#008000",
|
|
59
|
+
greenyellow: "#adff2f",
|
|
60
|
+
grey: "#808080",
|
|
61
|
+
honeydew: "#f0fff0",
|
|
62
|
+
hotpink: "#ff69b4",
|
|
63
|
+
indianred: "#cd5c5c",
|
|
64
|
+
indigo: "#4b0082",
|
|
65
|
+
ivory: "#fffff0",
|
|
66
|
+
khaki: "#f0e68c",
|
|
67
|
+
lavender: "#e6e6fa",
|
|
68
|
+
lavenderblush: "#fff0f5",
|
|
69
|
+
lawngreen: "#7cfc00",
|
|
70
|
+
lemonchiffon: "#fffacd",
|
|
71
|
+
lightblue: "#add8e6",
|
|
72
|
+
lightcoral: "#f08080",
|
|
73
|
+
lightcyan: "#e0ffff",
|
|
74
|
+
lightgoldenrodyellow: "#fafad2",
|
|
75
|
+
lightgray: "#d3d3d3",
|
|
76
|
+
lightgreen: "#90ee90",
|
|
77
|
+
lightgrey: "#d3d3d3",
|
|
78
|
+
lightpink: "#ffb6c1",
|
|
79
|
+
lightsalmon: "#ffa07a",
|
|
80
|
+
lightseagreen: "#20b2aa",
|
|
81
|
+
lightskyblue: "#87cefa",
|
|
82
|
+
lightslategray: "#778899",
|
|
83
|
+
lightslategrey: "#778899",
|
|
84
|
+
lightsteelblue: "#b0c4de",
|
|
85
|
+
lightyellow: "#ffffe0",
|
|
86
|
+
lime: "#00ff00",
|
|
87
|
+
limegreen: "#32cd32",
|
|
88
|
+
linen: "#faf0e6",
|
|
89
|
+
magenta: "#ff00ff",
|
|
90
|
+
maroon: "#800000",
|
|
91
|
+
mediumaquamarine: "#66cdaa",
|
|
92
|
+
mediumblue: "#0000cd",
|
|
93
|
+
mediumorchid: "#ba55d3",
|
|
94
|
+
mediumpurple: "#9370db",
|
|
95
|
+
mediumseagreen: "#3cb371",
|
|
96
|
+
mediumslateblue: "#7b68ee",
|
|
97
|
+
mediumspringgreen: "#00fa9a",
|
|
98
|
+
mediumturquoise: "#48d1cc",
|
|
99
|
+
mediumvioletred: "#c71585",
|
|
100
|
+
midnightblue: "#191970",
|
|
101
|
+
mintcream: "#f5fffa",
|
|
102
|
+
mistyrose: "#ffe4e1",
|
|
103
|
+
moccasin: "#ffe4b5",
|
|
104
|
+
navajowhite: "#ffdead",
|
|
105
|
+
navy: "#000080",
|
|
106
|
+
oldlace: "#fdf5e6",
|
|
107
|
+
olive: "#808000",
|
|
108
|
+
olivedrab: "#6b8e23",
|
|
109
|
+
orange: "#ffa500",
|
|
110
|
+
orangered: "#ff4500",
|
|
111
|
+
orchid: "#da70d6",
|
|
112
|
+
palegoldenrod: "#eee8aa",
|
|
113
|
+
palegreen: "#98fb98",
|
|
114
|
+
paleturquoise: "#afeeee",
|
|
115
|
+
palevioletred: "#db7093",
|
|
116
|
+
papayawhip: "#ffefd5",
|
|
117
|
+
peachpuff: "#ffdab9",
|
|
118
|
+
peru: "#cd853f",
|
|
119
|
+
pink: "#ffc0cb",
|
|
120
|
+
plum: "#dda0dd",
|
|
121
|
+
powderblue: "#b0e0e6",
|
|
122
|
+
purple: "#800080",
|
|
123
|
+
rebeccapurple: "#663399",
|
|
124
|
+
red: "#ff0000",
|
|
125
|
+
rosybrown: "#bc8f8f",
|
|
126
|
+
royalblue: "#4169e1",
|
|
127
|
+
saddlebrown: "#8b4513",
|
|
128
|
+
salmon: "#fa8072",
|
|
129
|
+
sandybrown: "#f4a460",
|
|
130
|
+
seagreen: "#2e8b57",
|
|
131
|
+
seashell: "#fff5ee",
|
|
132
|
+
sienna: "#a0522d",
|
|
133
|
+
silver: "#c0c0c0",
|
|
134
|
+
skyblue: "#87ceeb",
|
|
135
|
+
slateblue: "#6a5acd",
|
|
136
|
+
slategray: "#708090",
|
|
137
|
+
slategrey: "#708090",
|
|
138
|
+
snow: "#fffafa",
|
|
139
|
+
springgreen: "#00ff7f",
|
|
140
|
+
steelblue: "#4682b4",
|
|
141
|
+
tan: "#d2b48c",
|
|
142
|
+
teal: "#008080",
|
|
143
|
+
thistle: "#d8bfd8",
|
|
144
|
+
tomato: "#ff6347",
|
|
145
|
+
transparent: "#00000000",
|
|
146
|
+
turquoise: "#40e0d0",
|
|
147
|
+
violet: "#ee82ee",
|
|
148
|
+
wheat: "#f5deb3",
|
|
149
|
+
white: "#ffffff",
|
|
150
|
+
whitesmoke: "#f5f5f5",
|
|
151
|
+
yellow: "#ffff00",
|
|
152
|
+
yellowgreen: "#9acd32",
|
|
153
|
+
};
|
|
154
|
+
const hueToRgb = (p, q, t) => {
|
|
155
|
+
let h = t;
|
|
156
|
+
if (h < 0)
|
|
157
|
+
h += 1;
|
|
158
|
+
if (h > 1)
|
|
159
|
+
h -= 1;
|
|
160
|
+
if (h < 1 / 6)
|
|
161
|
+
return p + (q - p) * 6 * h;
|
|
162
|
+
if (h < 1 / 2)
|
|
163
|
+
return q;
|
|
164
|
+
if (h < 2 / 3)
|
|
165
|
+
return p + (q - p) * (2 / 3 - h) * 6;
|
|
166
|
+
return p;
|
|
167
|
+
};
|
|
168
|
+
const hslToRgb = (h, s, l) => {
|
|
169
|
+
if (s === 0) {
|
|
170
|
+
const v = Math.round(l * 255);
|
|
171
|
+
return [v, v, v];
|
|
172
|
+
}
|
|
173
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
174
|
+
const p = 2 * l - q;
|
|
175
|
+
return [
|
|
176
|
+
Math.round(hueToRgb(p, q, h + 1 / 3) * 255),
|
|
177
|
+
Math.round(hueToRgb(p, q, h) * 255),
|
|
178
|
+
Math.round(hueToRgb(p, q, h - 1 / 3) * 255),
|
|
179
|
+
];
|
|
180
|
+
};
|
|
181
|
+
const parseColor = (input) => {
|
|
182
|
+
let color = input.trim().toLowerCase();
|
|
183
|
+
const named = NAMED_COLORS[color];
|
|
184
|
+
if (named)
|
|
185
|
+
color = named;
|
|
186
|
+
if (color.startsWith("#")) {
|
|
187
|
+
const hex = color.slice(1);
|
|
188
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
189
|
+
const r = Number.parseInt(hex.charAt(0) + hex.charAt(0), 16);
|
|
190
|
+
const g = Number.parseInt(hex.charAt(1) + hex.charAt(1), 16);
|
|
191
|
+
const b = Number.parseInt(hex.charAt(2) + hex.charAt(2), 16);
|
|
192
|
+
const a = hex.length === 4 ? Number.parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255 : 1;
|
|
193
|
+
return { r, g, b, a };
|
|
194
|
+
}
|
|
195
|
+
if (hex.length === 6 || hex.length === 8) {
|
|
196
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
197
|
+
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
198
|
+
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
199
|
+
const a = hex.length === 8 ? Number.parseInt(hex.slice(6, 8), 16) / 255 : 1;
|
|
200
|
+
return { r, g, b, a };
|
|
201
|
+
}
|
|
202
|
+
throw new Error(`interpolateColors(): invalid hex color "${input}"`);
|
|
203
|
+
}
|
|
204
|
+
const rgbMatch = color.match(/^rgba?\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*(?:,\s*(-?\d+(?:\.\d+)?)\s*)?\)$/);
|
|
205
|
+
if (rgbMatch) {
|
|
206
|
+
return {
|
|
207
|
+
r: Number(rgbMatch[1]),
|
|
208
|
+
g: Number(rgbMatch[2]),
|
|
209
|
+
b: Number(rgbMatch[3]),
|
|
210
|
+
a: rgbMatch[4] !== undefined ? Number(rgbMatch[4]) : 1,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const hslMatch = color.match(/^hsla?\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*(?:,\s*(-?\d+(?:\.\d+)?)\s*)?\)$/);
|
|
214
|
+
if (hslMatch) {
|
|
215
|
+
const h = (((Number(hslMatch[1]) % 360) + 360) % 360) / 360;
|
|
216
|
+
const s = Number(hslMatch[2]) / 100;
|
|
217
|
+
const l = Number(hslMatch[3]) / 100;
|
|
218
|
+
const [r, g, b] = hslToRgb(h, s, l);
|
|
219
|
+
const a = hslMatch[4] !== undefined ? Number(hslMatch[4]) : 1;
|
|
220
|
+
return { r, g, b, a };
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`interpolateColors(): unsupported color format "${input}"`);
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Interpolates between a list of colors. API-compatible with Remotion's
|
|
226
|
+
* `interpolateColors`. Returns an `rgba(r, g, b, a)` string. Extrapolation
|
|
227
|
+
* is clamped on both sides.
|
|
228
|
+
*/
|
|
229
|
+
export const interpolateColors = (input, inputRange, outputRange) => {
|
|
230
|
+
if (inputRange.length !== outputRange.length) {
|
|
231
|
+
throw new Error("interpolateColors(): inputRange and outputRange must have the same length");
|
|
232
|
+
}
|
|
233
|
+
const parsed = outputRange.map(parseColor);
|
|
234
|
+
const r = Math.round(interpolate(input, inputRange, parsed.map((c) => c.r), { extrapolateLeft: "clamp", extrapolateRight: "clamp" }));
|
|
235
|
+
const g = Math.round(interpolate(input, inputRange, parsed.map((c) => c.g), { extrapolateLeft: "clamp", extrapolateRight: "clamp" }));
|
|
236
|
+
const b = Math.round(interpolate(input, inputRange, parsed.map((c) => c.b), { extrapolateLeft: "clamp", extrapolateRight: "clamp" }));
|
|
237
|
+
const a = interpolate(input, inputRange, parsed.map((c) => c.a), { extrapolateLeft: "clamp", extrapolateRight: "clamp" });
|
|
238
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
239
|
+
};
|
|
240
|
+
//# sourceMappingURL=interpolate-colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate-colors.js","sourceRoot":"","sources":["../src/interpolate-colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C,+CAA+C;AAC/C,MAAM,YAAY,GAA2B;IAC3C,SAAS,EAAE,SAAS;IACpB,YAAY,EAAE,SAAS;IACvB,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,cAAc,EAAE,SAAS;IACzB,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,SAAS;IACpB,SAAS,EAAE,SAAS;IACpB,UAAU,EAAE,SA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AAgB,EAAE,OAAO,EAAE,CACxD,CACF,CAAC;IACF,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAClB,WAAW,CACT,KAAK,EACL,UAAU,EACV,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EACtB,EAAE,eAAe,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,CACxD,CACF,CAAC;IACF,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAClB,WAAW,CACT,KAAK,EACL,UAAU,EACV,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EACtB,EAAE,eAAe,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,CACxD,CACF,CAAC;IACF,MAAM,CAAC,GAAG,WAAW,CACnB,KAAK,EACL,UAAU,EACV,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EACtB,EAAE,eAAe,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,CACxD,CAAC;IAEF,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ExtrapolateType = "extend" | "identity" | "clamp" | "wrap";
|
|
2
|
+
export type InterpolateOptions = {
|
|
3
|
+
easing?: (input: number) => number;
|
|
4
|
+
extrapolateLeft?: ExtrapolateType;
|
|
5
|
+
extrapolateRight?: ExtrapolateType;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Maps `input` from `inputRange` onto `outputRange`. API-compatible with
|
|
9
|
+
* Remotion's `interpolate`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const interpolate: (input: number, inputRange: readonly number[], outputRange: readonly number[], options?: InterpolateOptions) => number;
|
|
12
|
+
//# sourceMappingURL=interpolate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../src/interpolate.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAEvE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,gBAAgB,CAAC,EAAE,eAAe,CAAC;CACpC,CAAC;AAgDF;;;GAGG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,MAAM,EACb,YAAY,SAAS,MAAM,EAAE,EAC7B,aAAa,SAAS,MAAM,EAAE,EAC9B,UAAU,kBAAkB,KAC3B,MAiCF,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const findRange = (input, inputRange) => {
|
|
2
|
+
let i = 1;
|
|
3
|
+
for (; i < inputRange.length - 1; i++) {
|
|
4
|
+
if (inputRange[i] >= input)
|
|
5
|
+
break;
|
|
6
|
+
}
|
|
7
|
+
return i - 1;
|
|
8
|
+
};
|
|
9
|
+
const interpolateSegment = (input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight) => {
|
|
10
|
+
let result = input;
|
|
11
|
+
if (result < inputMin) {
|
|
12
|
+
if (extrapolateLeft === "identity")
|
|
13
|
+
return result;
|
|
14
|
+
if (extrapolateLeft === "clamp")
|
|
15
|
+
result = inputMin;
|
|
16
|
+
else if (extrapolateLeft === "wrap") {
|
|
17
|
+
const range = inputMax - inputMin;
|
|
18
|
+
result = ((((result - inputMin) % range) + range) % range) + inputMin;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (result > inputMax) {
|
|
22
|
+
if (extrapolateRight === "identity")
|
|
23
|
+
return result;
|
|
24
|
+
if (extrapolateRight === "clamp")
|
|
25
|
+
result = inputMax;
|
|
26
|
+
else if (extrapolateRight === "wrap") {
|
|
27
|
+
const range = inputMax - inputMin;
|
|
28
|
+
result = ((((result - inputMin) % range) + range) % range) + inputMin;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (outputMin === outputMax)
|
|
32
|
+
return outputMin;
|
|
33
|
+
// Normalize and ease.
|
|
34
|
+
let t = (result - inputMin) / (inputMax - inputMin);
|
|
35
|
+
t = easing(t);
|
|
36
|
+
return outputMin + t * (outputMax - outputMin);
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Maps `input` from `inputRange` onto `outputRange`. API-compatible with
|
|
40
|
+
* Remotion's `interpolate`.
|
|
41
|
+
*/
|
|
42
|
+
export const interpolate = (input, inputRange, outputRange, options) => {
|
|
43
|
+
if (typeof input !== "number") {
|
|
44
|
+
throw new TypeError("interpolate(): input must be a number");
|
|
45
|
+
}
|
|
46
|
+
if (inputRange.length < 2 || outputRange.length < 2) {
|
|
47
|
+
throw new Error("interpolate(): inputRange and outputRange must have at least 2 elements");
|
|
48
|
+
}
|
|
49
|
+
if (inputRange.length !== outputRange.length) {
|
|
50
|
+
throw new Error("interpolate(): inputRange and outputRange must have the same length");
|
|
51
|
+
}
|
|
52
|
+
for (let i = 1; i < inputRange.length; i++) {
|
|
53
|
+
if (!(inputRange[i] > inputRange[i - 1])) {
|
|
54
|
+
throw new Error("interpolate(): inputRange must be strictly monotonically increasing");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (Number.isNaN(input))
|
|
58
|
+
return input;
|
|
59
|
+
const easing = options?.easing ?? ((n) => n);
|
|
60
|
+
const extrapolateLeft = options?.extrapolateLeft ?? "extend";
|
|
61
|
+
const extrapolateRight = options?.extrapolateRight ?? "extend";
|
|
62
|
+
const i = findRange(input, inputRange);
|
|
63
|
+
return interpolateSegment(input, inputRange[i], inputRange[i + 1], outputRange[i], outputRange[i + 1], easing, extrapolateLeft, extrapolateRight);
|
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