@zync/zync-screnplay-player 0.1.240 → 0.1.242

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.
@@ -0,0 +1,264 @@
1
+ import React from "react";
2
+ import { Easing, interpolate, useCurrentFrame, useVideoConfig } from "remotion";
3
+ import { loadFont } from "@remotion/google-fonts/Kanit";
4
+ import { useOrientationBased } from "../../../hooks/useOrientationBased.js";
5
+ import { useTheme } from "../../hooks/useTheme.js";
6
+ import { getContrastColor } from "../../../helpers/getContrastColor";
7
+ var _loadFont = loadFont("normal", {
8
+ subsets: ["latin"],
9
+ weights: ["400", "500", "600"]
10
+ }),
11
+ fontFamily = _loadFont.fontFamily;
12
+ var clamp = function clamp(value, min, max) {
13
+ return Math.max(min, Math.min(max, value));
14
+ };
15
+ var estimateTextWidth = function estimateTextWidth(text, fontSize) {
16
+ return text.length * fontSize * 0.62;
17
+ };
18
+ var fitSingleLineFontSize = function fitSingleLineFontSize(text, maxWidth, maxHeight, maxFontSize) {
19
+ if (!text) {
20
+ return maxFontSize;
21
+ }
22
+ var estimatedWidthAtOnePixel = estimateTextWidth(text, 1);
23
+ return Math.floor(clamp(maxWidth / estimatedWidthAtOnePixel, 1, Math.min(maxFontSize, maxHeight)));
24
+ };
25
+ export var RightslideNametag = function RightslideNametag(_ref) {
26
+ var name = _ref.name,
27
+ title = _ref.title,
28
+ themeSettings = _ref.themeSettings;
29
+ var frame = useCurrentFrame();
30
+ var _useVideoConfig = useVideoConfig(),
31
+ fps = _useVideoConfig.fps,
32
+ width = _useVideoConfig.width,
33
+ height = _useVideoConfig.height;
34
+ var _useTheme = useTheme(),
35
+ primaryColor = _useTheme.primaryColor,
36
+ accentColor = _useTheme.accentColor;
37
+ var _useOrientationBased = useOrientationBased({
38
+ landscape: {
39
+ containerBottom: height * 0.11,
40
+ containerRight: width * 0.04,
41
+ lineWidth: clamp(width * 0.004, 5, 8),
42
+ maxNameBoxWidth: width * 0.62,
43
+ maxNameFontSize: width * 0.07,
44
+ maxTitleFontSize: width * 0.032,
45
+ nameBoxHeight: height * 0.102,
46
+ titleBoxHeight: height * 0.052,
47
+ titleGap: height * 0.012
48
+ },
49
+ portrait: {
50
+ containerBottom: height * 0.2,
51
+ containerLeft: width * 0.07,
52
+ lineWidth: clamp(width * 0.01, 5, 8),
53
+ maxNameBoxWidth: width * 0.84,
54
+ maxNameFontSize: width * 0.12,
55
+ maxTitleFontSize: width * 0.056,
56
+ nameBoxHeight: height * 0.066,
57
+ titleBoxHeight: height * 0.038,
58
+ titleGap: height * 0.008
59
+ },
60
+ square: {
61
+ containerBottom: height * 0.15,
62
+ containerRight: width * 0.06,
63
+ lineWidth: clamp(width * 0.007, 5, 8),
64
+ maxNameBoxWidth: width * 0.78,
65
+ maxNameFontSize: width * 0.095,
66
+ maxTitleFontSize: width * 0.045,
67
+ nameBoxHeight: height * 0.078,
68
+ titleBoxHeight: height * 0.046,
69
+ titleGap: height * 0.01
70
+ }
71
+ }),
72
+ containerBottom = _useOrientationBased.containerBottom,
73
+ containerLeft = _useOrientationBased.containerLeft,
74
+ containerRight = _useOrientationBased.containerRight,
75
+ lineWidth = _useOrientationBased.lineWidth,
76
+ maxNameBoxWidth = _useOrientationBased.maxNameBoxWidth,
77
+ maxNameFontSize = _useOrientationBased.maxNameFontSize,
78
+ maxTitleFontSize = _useOrientationBased.maxTitleFontSize,
79
+ nameBoxHeight = _useOrientationBased.nameBoxHeight,
80
+ titleBoxHeight = _useOrientationBased.titleBoxHeight,
81
+ titleGap = _useOrientationBased.titleGap;
82
+ var displayName = (name || "").toLocaleUpperCase();
83
+ var displayTitle = (title || "").toLocaleUpperCase();
84
+ var boxColor = (themeSettings === null || themeSettings === void 0 ? void 0 : themeSettings.secondaryColor) || accentColor || primaryColor || "#ff6a00";
85
+ var textColor = getContrastColor(boxColor) || "#FFFFFF";
86
+ var namePadding = nameBoxHeight * 0.22;
87
+ var titlePadding = titleBoxHeight * 0.26;
88
+ var nameFontSize = fitSingleLineFontSize(displayName, maxNameBoxWidth - namePadding * 2, nameBoxHeight * 0.82, maxNameFontSize);
89
+ var titleFontSize = fitSingleLineFontSize(displayTitle, maxNameBoxWidth - titlePadding * 2, titleBoxHeight * 0.66, maxTitleFontSize);
90
+ var titleBoxMaxWidth = maxNameBoxWidth;
91
+ var fullHeight = nameBoxHeight + titleGap + titleBoxHeight;
92
+ var lineEnd = Math.round(fps * 0.28);
93
+ var boxStart = lineEnd;
94
+ var boxEnd = boxStart + Math.round(fps * 1.3);
95
+ var whiteEnd = boxEnd;
96
+ var nameRevealStart = boxStart + Math.round(fps * 0.2);
97
+ var nameRevealEnd = nameRevealStart + Math.round(fps * 0.9);
98
+ var titleEnd = boxStart + Math.round(fps * 0.62);
99
+ var lineProgress = interpolate(frame, [0, lineEnd], [0, 1], {
100
+ easing: Easing.out(Easing.cubic),
101
+ extrapolateLeft: "clamp",
102
+ extrapolateRight: "clamp"
103
+ });
104
+ var nameBoxProgress = interpolate(frame, [boxStart, boxEnd], [0, 1], {
105
+ easing: Easing.inOut(Easing.quad),
106
+ extrapolateLeft: "clamp",
107
+ extrapolateRight: "clamp"
108
+ });
109
+ var whiteMoveProgress = interpolate(frame, [boxStart, whiteEnd], [0, 1], {
110
+ easing: Easing.out(Easing.quad),
111
+ extrapolateLeft: "clamp",
112
+ extrapolateRight: "clamp"
113
+ });
114
+ var whiteWidth = interpolate(whiteMoveProgress, [0, 0.5, 1], [lineWidth * 1.4, nameBoxHeight * 1.45, lineWidth], {
115
+ extrapolateLeft: "clamp",
116
+ extrapolateRight: "clamp"
117
+ });
118
+ var whiteLeft = interpolate(whiteMoveProgress, [0, 0.5, 1], [100, 42, 0], {
119
+ extrapolateLeft: "clamp",
120
+ extrapolateRight: "clamp"
121
+ });
122
+ var whiteOpacity = interpolate(frame, [boxStart, boxStart + 1], [0, 1], {
123
+ extrapolateLeft: "clamp",
124
+ extrapolateRight: "clamp"
125
+ });
126
+ var nameReveal = interpolate(frame, [nameRevealStart, nameRevealEnd], [0, 1], {
127
+ easing: Easing.out(Easing.cubic),
128
+ extrapolateLeft: "clamp",
129
+ extrapolateRight: "clamp"
130
+ });
131
+ var visibleNameProgress = Math.min(nameReveal, nameBoxProgress);
132
+ var titleProgress = interpolate(frame, [boxStart, titleEnd], [0, 1], {
133
+ easing: Easing.out(Easing.cubic),
134
+ extrapolateLeft: "clamp",
135
+ extrapolateRight: "clamp"
136
+ });
137
+ var titleTextProgress = interpolate(titleProgress, [0.16, 1], [0, 1], {
138
+ easing: Easing.out(Easing.cubic),
139
+ extrapolateLeft: "clamp",
140
+ extrapolateRight: "clamp"
141
+ });
142
+ var titleTextTranslate = interpolate(titleTextProgress, [0, 1], [-titleBoxHeight * 1.15, 0], {
143
+ extrapolateLeft: "clamp",
144
+ extrapolateRight: "clamp"
145
+ });
146
+ return /*#__PURE__*/React.createElement("div", {
147
+ style: {
148
+ bottom: containerBottom,
149
+ fontFamily: fontFamily,
150
+ left: containerLeft,
151
+ position: "absolute",
152
+ right: containerRight,
153
+ width: maxNameBoxWidth + lineWidth
154
+ }
155
+ }, /*#__PURE__*/React.createElement("div", {
156
+ style: {
157
+ height: fullHeight,
158
+ position: "relative",
159
+ width: "100%"
160
+ }
161
+ }, /*#__PURE__*/React.createElement("div", {
162
+ style: {
163
+ backgroundColor: "#FFFFFF",
164
+ height: "100%",
165
+ position: "absolute",
166
+ right: 0,
167
+ top: 0,
168
+ transform: "scaleY(".concat(lineProgress, ")"),
169
+ transformOrigin: "top",
170
+ width: lineWidth
171
+ }
172
+ }), /*#__PURE__*/React.createElement("div", {
173
+ style: {
174
+ boxSizing: "border-box",
175
+ height: nameBoxHeight,
176
+ maxWidth: maxNameBoxWidth,
177
+ overflow: "hidden",
178
+ padding: "0 ".concat(namePadding, "px"),
179
+ position: "absolute",
180
+ right: lineWidth,
181
+ top: 0,
182
+ width: "fit-content"
183
+ }
184
+ }, /*#__PURE__*/React.createElement("div", {
185
+ style: {
186
+ backgroundColor: boxColor,
187
+ height: "100%",
188
+ position: "absolute",
189
+ right: 0,
190
+ top: 0,
191
+ transform: "scaleX(".concat(nameBoxProgress, ")"),
192
+ transformOrigin: "right",
193
+ width: "100%"
194
+ }
195
+ }), /*#__PURE__*/React.createElement("div", {
196
+ style: {
197
+ backgroundColor: "#FFFFFF",
198
+ height: "100%",
199
+ left: "".concat(whiteLeft, "%"),
200
+ opacity: whiteOpacity,
201
+ position: "absolute",
202
+ top: 0,
203
+ width: whiteWidth,
204
+ zIndex: 2
205
+ }
206
+ }), /*#__PURE__*/React.createElement("div", {
207
+ style: {
208
+ alignItems: "center",
209
+ clipPath: "inset(0 0 0 ".concat((1 - visibleNameProgress) * 100, "%)"),
210
+ color: textColor,
211
+ display: "flex",
212
+ fontSize: nameFontSize,
213
+ fontWeight: 400,
214
+ height: "100%",
215
+ lineHeight: 1,
216
+ overflow: "hidden",
217
+ position: "relative",
218
+ textShadow: "0 1px 5px rgba(0, 0, 0, 0.32)",
219
+ whiteSpace: "nowrap",
220
+ zIndex: 1
221
+ }
222
+ }, displayName)), /*#__PURE__*/React.createElement("div", {
223
+ style: {
224
+ boxSizing: "border-box",
225
+ height: titleBoxHeight,
226
+ maxWidth: titleBoxMaxWidth,
227
+ overflow: "hidden",
228
+ padding: "0 ".concat(titlePadding, "px"),
229
+ position: "absolute",
230
+ right: lineWidth,
231
+ top: nameBoxHeight + titleGap,
232
+ width: "fit-content"
233
+ }
234
+ }, /*#__PURE__*/React.createElement("div", {
235
+ style: {
236
+ backgroundColor: boxColor,
237
+ height: "100%",
238
+ position: "absolute",
239
+ right: 0,
240
+ top: 0,
241
+ transform: "scaleX(".concat(titleProgress, ")"),
242
+ transformOrigin: "right",
243
+ width: "100%"
244
+ }
245
+ }), /*#__PURE__*/React.createElement("div", {
246
+ style: {
247
+ alignItems: "center",
248
+ clipPath: "inset(0 0 0 ".concat((1 - titleProgress) * 100, "%)"),
249
+ color: textColor,
250
+ display: "flex",
251
+ fontSize: titleFontSize,
252
+ fontWeight: 400,
253
+ height: "100%",
254
+ letterSpacing: "0.08em",
255
+ lineHeight: 1,
256
+ overflow: "hidden",
257
+ position: "relative",
258
+ textShadow: "0 1px 4px rgba(0, 0, 0, 0.28)",
259
+ transform: "translateX(".concat(titleTextTranslate, "px)"),
260
+ whiteSpace: "nowrap",
261
+ zIndex: 1
262
+ }
263
+ }, displayTitle))));
264
+ };
@@ -0,0 +1,212 @@
1
+ import React from "react";
2
+ import { Easing, interpolate, useCurrentFrame, useVideoConfig } from "remotion";
3
+ import { loadFont } from "@remotion/google-fonts/Kanit";
4
+ import { useOrientationBased } from "../../../hooks/useOrientationBased.js";
5
+ import { useTheme } from "../../hooks/useTheme.js";
6
+ import { getContrastColor } from "../../../helpers/getContrastColor";
7
+ var _loadFont = loadFont("normal", {
8
+ subsets: ["latin"],
9
+ weights: ["400", "500", "600"]
10
+ }),
11
+ fontFamily = _loadFont.fontFamily;
12
+ var clamp = function clamp(value, min, max) {
13
+ return Math.max(min, Math.min(max, value));
14
+ };
15
+ var estimateTextWidth = function estimateTextWidth(text, fontSize) {
16
+ return text.length * fontSize * 0.62;
17
+ };
18
+ var fitSingleLineFontSize = function fitSingleLineFontSize(text, maxWidth, maxHeight, maxFontSize) {
19
+ if (!text) {
20
+ return maxFontSize;
21
+ }
22
+ var estimatedWidthAtOnePixel = estimateTextWidth(text, 1);
23
+ return Math.floor(clamp(maxWidth / estimatedWidthAtOnePixel, 1, Math.min(maxFontSize, maxHeight)));
24
+ };
25
+ export var StackfillNametag = function StackfillNametag(_ref) {
26
+ var name = _ref.name,
27
+ title = _ref.title,
28
+ themeSettings = _ref.themeSettings;
29
+ var frame = useCurrentFrame();
30
+ var _useVideoConfig = useVideoConfig(),
31
+ fps = _useVideoConfig.fps,
32
+ width = _useVideoConfig.width,
33
+ height = _useVideoConfig.height;
34
+ var _useTheme = useTheme(),
35
+ primaryColor = _useTheme.primaryColor,
36
+ accentColor = _useTheme.accentColor;
37
+ var _useOrientationBased = useOrientationBased({
38
+ landscape: {
39
+ containerBottom: height * 0.11,
40
+ containerLeft: width * 0.04,
41
+ maxNameBoxWidth: width * 0.62,
42
+ maxNameFontSize: width * 0.07,
43
+ maxTitleFontSize: width * 0.033,
44
+ nameBoxHeight: height * 0.102,
45
+ titleBoxHeight: height * 0.052,
46
+ titleGap: height * 0.012
47
+ },
48
+ portrait: {
49
+ containerBottom: height * 0.2,
50
+ containerLeft: width * 0.07,
51
+ maxNameBoxWidth: width * 0.84,
52
+ maxNameFontSize: width * 0.12,
53
+ maxTitleFontSize: width * 0.058,
54
+ nameBoxHeight: height * 0.066,
55
+ titleBoxHeight: height * 0.038,
56
+ titleGap: height * 0.008
57
+ },
58
+ square: {
59
+ containerBottom: height * 0.15,
60
+ containerLeft: width * 0.06,
61
+ maxNameBoxWidth: width * 0.78,
62
+ maxNameFontSize: width * 0.095,
63
+ maxTitleFontSize: width * 0.046,
64
+ nameBoxHeight: height * 0.078,
65
+ titleBoxHeight: height * 0.046,
66
+ titleGap: height * 0.01
67
+ }
68
+ }),
69
+ containerBottom = _useOrientationBased.containerBottom,
70
+ containerLeft = _useOrientationBased.containerLeft,
71
+ maxNameBoxWidth = _useOrientationBased.maxNameBoxWidth,
72
+ maxNameFontSize = _useOrientationBased.maxNameFontSize,
73
+ maxTitleFontSize = _useOrientationBased.maxTitleFontSize,
74
+ nameBoxHeight = _useOrientationBased.nameBoxHeight,
75
+ titleBoxHeight = _useOrientationBased.titleBoxHeight,
76
+ titleGap = _useOrientationBased.titleGap;
77
+ var displayName = (name || "").toLocaleUpperCase();
78
+ var displayTitle = (title || "").toLocaleUpperCase();
79
+ var boxColor = (themeSettings === null || themeSettings === void 0 ? void 0 : themeSettings.secondaryColor) || accentColor || primaryColor || "#ff6a00";
80
+ var textColor = getContrastColor(boxColor) || "#FFFFFF";
81
+ var namePadding = nameBoxHeight * 0.22;
82
+ var titlePadding = titleBoxHeight * 0.22;
83
+ var nameFontSize = fitSingleLineFontSize(displayName, maxNameBoxWidth - namePadding * 2, nameBoxHeight * 0.84, maxNameFontSize);
84
+ var titleFontSize = fitSingleLineFontSize(displayTitle, maxNameBoxWidth - titlePadding * 2, titleBoxHeight * 0.66, maxTitleFontSize);
85
+ var widthEnd = Math.round(fps * 0.7);
86
+ var titleBoxShowStart = widthEnd + Math.round(fps * 0.08);
87
+ var fillStart = titleBoxShowStart + Math.round(fps * 0.08);
88
+ var fillEnd = fillStart + Math.round(fps * 0.7);
89
+ var widthProgress = interpolate(frame, [0, widthEnd], [0, 1], {
90
+ easing: Easing.out(Easing.cubic),
91
+ extrapolateLeft: "clamp",
92
+ extrapolateRight: "clamp"
93
+ });
94
+ var fillProgress = interpolate(frame, [fillStart, fillEnd], [0, 1], {
95
+ easing: Easing.out(Easing.cubic),
96
+ extrapolateLeft: "clamp",
97
+ extrapolateRight: "clamp"
98
+ });
99
+ var titleBoxOpacity = interpolate(frame, [titleBoxShowStart, titleBoxShowStart + 1], [0, 1], {
100
+ extrapolateLeft: "clamp",
101
+ extrapolateRight: "clamp"
102
+ });
103
+ var textProgress = interpolate(fillProgress, [0.5, 1], [0, 1], {
104
+ easing: Easing.out(Easing.cubic),
105
+ extrapolateLeft: "clamp",
106
+ extrapolateRight: "clamp"
107
+ });
108
+ var nameTranslateY = interpolate(textProgress, [0, 1], [nameBoxHeight * 0.44, 0], {
109
+ extrapolateLeft: "clamp",
110
+ extrapolateRight: "clamp"
111
+ });
112
+ return /*#__PURE__*/React.createElement("div", {
113
+ style: {
114
+ bottom: containerBottom,
115
+ fontFamily: fontFamily,
116
+ left: containerLeft,
117
+ position: "absolute",
118
+ width: maxNameBoxWidth
119
+ }
120
+ }, /*#__PURE__*/React.createElement("div", {
121
+ style: {
122
+ boxSizing: "border-box",
123
+ height: nameBoxHeight,
124
+ maxWidth: maxNameBoxWidth,
125
+ overflow: "hidden",
126
+ padding: "0 ".concat(namePadding, "px"),
127
+ position: "relative",
128
+ width: "fit-content"
129
+ }
130
+ }, /*#__PURE__*/React.createElement("div", {
131
+ style: {
132
+ backgroundColor: "#FFFFFF",
133
+ height: "100%",
134
+ left: 0,
135
+ position: "absolute",
136
+ top: 0,
137
+ transform: "scaleX(".concat(widthProgress, ")"),
138
+ transformOrigin: "left",
139
+ width: "100%"
140
+ }
141
+ }), /*#__PURE__*/React.createElement("div", {
142
+ style: {
143
+ backgroundColor: boxColor,
144
+ height: "".concat(fillProgress * 88, "%"),
145
+ left: 0,
146
+ position: "absolute",
147
+ top: 0,
148
+ width: "100%"
149
+ }
150
+ }), /*#__PURE__*/React.createElement("div", {
151
+ style: {
152
+ alignItems: "center",
153
+ color: textColor,
154
+ display: "flex",
155
+ fontSize: nameFontSize,
156
+ fontWeight: 400,
157
+ height: "88%",
158
+ lineHeight: 1,
159
+ opacity: textProgress,
160
+ overflow: "hidden",
161
+ position: "relative",
162
+ textShadow: "0 1px 5px rgba(0, 0, 0, 0.32)",
163
+ transform: "translateY(".concat(nameTranslateY, "px)"),
164
+ whiteSpace: "nowrap",
165
+ zIndex: 1
166
+ }
167
+ }, displayName)), /*#__PURE__*/React.createElement("div", {
168
+ style: {
169
+ boxSizing: "border-box",
170
+ height: titleBoxHeight,
171
+ marginTop: titleGap,
172
+ maxWidth: maxNameBoxWidth,
173
+ opacity: titleBoxOpacity,
174
+ overflow: "hidden",
175
+ padding: "0 ".concat(titlePadding, "px"),
176
+ position: "relative",
177
+ width: "fit-content"
178
+ }
179
+ }, /*#__PURE__*/React.createElement("div", {
180
+ style: {
181
+ backgroundColor: boxColor,
182
+ height: "".concat(fillProgress * 100, "%"),
183
+ left: 0,
184
+ position: "absolute",
185
+ top: 0,
186
+ width: "100%"
187
+ }
188
+ }), /*#__PURE__*/React.createElement("div", {
189
+ style: {
190
+ alignItems: "center",
191
+ color: textColor,
192
+ display: "flex",
193
+ fontSize: titleFontSize,
194
+ fontWeight: 400,
195
+ height: "".concat(fillProgress * 100, "%"),
196
+ letterSpacing: "0.08em",
197
+ lineHeight: 1,
198
+ opacity: titleBoxOpacity,
199
+ overflow: "hidden",
200
+ position: "relative",
201
+ textShadow: "0 1px 4px rgba(0, 0, 0, 0.28)",
202
+ whiteSpace: "nowrap",
203
+ zIndex: 1
204
+ }
205
+ }, /*#__PURE__*/React.createElement("span", {
206
+ style: {
207
+ alignItems: "center",
208
+ display: "flex",
209
+ height: titleBoxHeight
210
+ }
211
+ }, displayTitle))));
212
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zync/zync-screnplay-player",
3
- "version": "0.1.240",
3
+ "version": "0.1.242",
4
4
  "files": [
5
5
  "dist"
6
6
  ],