@zync/zync-screnplay-player 0.1.245 → 0.1.247

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.
Files changed (69) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/screenplay/RemotionRenderer/components/LottieAnimationGlobal.js +21 -21
  3. package/dist/screenplay/RemotionRenderer/components/layouts/BrollGreenScreen.js +46 -44
  4. package/dist/screenplay/RemotionRenderer/components/layouts/CreatorCollabColdOpenVisual.js +3 -6
  5. package/dist/screenplay/RemotionRenderer/components/layouts/CreatorCollabConversationSpine.js +3 -6
  6. package/dist/screenplay/RemotionRenderer/components/layouts/CreatorCollabDocumentaryInset.js +3 -6
  7. package/dist/screenplay/RemotionRenderer/components/layouts/CreatorCollabRackFocus.js +3 -6
  8. package/dist/screenplay/RemotionRenderer/components/layouts/CreatorCollabSplit.js +2 -3
  9. package/dist/screenplay/RemotionRenderer/components/layouts/CreatorCollabStudioSet.js +3 -6
  10. package/dist/screenplay/RemotionRenderer/components/layouts/DynamicTriangle.js +2 -3
  11. package/dist/screenplay/RemotionRenderer/components/layouts/HookVideo.js +2 -3
  12. package/dist/screenplay/RemotionRenderer/components/layouts/IntroVideo.js +2 -3
  13. package/dist/screenplay/RemotionRenderer/components/layouts/KeyPointOverlayDepth.js +2 -3
  14. package/dist/screenplay/RemotionRenderer/components/layouts/Keyword.js +2 -3
  15. package/dist/screenplay/RemotionRenderer/components/layouts/KeywordStudioBackdrop.js +2 -3
  16. package/dist/screenplay/RemotionRenderer/components/layouts/MotionStill.js +2 -3
  17. package/dist/screenplay/RemotionRenderer/components/layouts/TextWithVideo.js +2 -3
  18. package/dist/screenplay/RemotionRenderer/components/utils/FaceCenteredVideo.js +66 -57
  19. package/dist/screenplay/RemotionRenderer/components/utils/PausableImg.js +4 -4
  20. package/dist/screenplay/RemotionRenderer/components/utils/README.md +80 -80
  21. package/dist/screenplay/RemotionRenderer/components/utils/StretchTextDemo.js +3 -3
  22. package/dist/screenplay/RemotionRenderer/development.js +1627 -924
  23. package/dist/screenplay/RemotionRenderer/fontRegistry.js +422 -0
  24. package/dist/screenplay/RemotionRenderer/helpers/convertToSeconds.js +8 -8
  25. package/dist/screenplay/RemotionRenderer/helpers/faceBasedVideoStyles.js +4 -4
  26. package/dist/screenplay/RemotionRenderer/helpers/faceCenteredVideoTransforms.js +46 -46
  27. package/dist/screenplay/RemotionRenderer/main/screenplaySchema.js +51 -51
  28. package/dist/screenplay/RemotionRenderer/registeredComponents.js +2 -2
  29. package/dist/screenplay/RemotionRenderer/theme/themes/bigbold/BigBoldNameTag.js +2 -3
  30. package/dist/screenplay/RemotionRenderer/theme/themes/bigbold/BigBoldSentence.js +2 -3
  31. package/dist/screenplay/RemotionRenderer/theme/themes/bigbold/BigBoldTitle.js +2 -3
  32. package/dist/screenplay/RemotionRenderer/theme/themes/boxwipe/Nametag.js +2 -6
  33. package/dist/screenplay/RemotionRenderer/theme/themes/centerline/Nametag.js +2 -6
  34. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionColor.js +2 -3
  35. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionColorInverse.js +2 -3
  36. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionColorShadow.js +2 -3
  37. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionElegant.js +3 -6
  38. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionEmphasis.js +2 -3
  39. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionPunctuated.js +2 -3
  40. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionWordBoom.js +2 -3
  41. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionWordBubble.js +2 -3
  42. package/dist/screenplay/RemotionRenderer/theme/themes/default/CaptionWordPopup.js +3 -6
  43. package/dist/screenplay/RemotionRenderer/theme/themes/default/DefaultCaption.js +2 -3
  44. package/dist/screenplay/RemotionRenderer/theme/themes/default/HandoffNametag.js +2 -3
  45. package/dist/screenplay/RemotionRenderer/theme/themes/default/Nametag.js +2 -3
  46. package/dist/screenplay/RemotionRenderer/theme/themes/default/Sentence.js +2 -3
  47. package/dist/screenplay/RemotionRenderer/theme/themes/default/Title.js +2 -3
  48. package/dist/screenplay/RemotionRenderer/theme/themes/fullcover/TextFullCover.js +2 -6
  49. package/dist/screenplay/RemotionRenderer/theme/themes/glassmorphism/Nametag.js +2 -3
  50. package/dist/screenplay/RemotionRenderer/theme/themes/glassmorphism/Sentence.js +2 -3
  51. package/dist/screenplay/RemotionRenderer/theme/themes/glassmorphism/Title.js +2 -3
  52. package/dist/screenplay/RemotionRenderer/theme/themes/glitch/GlitchNametag.js +2 -3
  53. package/dist/screenplay/RemotionRenderer/theme/themes/glitch/GlitchSentence.js +2 -3
  54. package/dist/screenplay/RemotionRenderer/theme/themes/glitch/GlitchTitle.js +2 -3
  55. package/dist/screenplay/RemotionRenderer/theme/themes/pushpull/PushPullNametag.js +2 -3
  56. package/dist/screenplay/RemotionRenderer/theme/themes/pushpull/PushPullSentence.js +2 -3
  57. package/dist/screenplay/RemotionRenderer/theme/themes/pushpull/PushPullTitle.js +2 -3
  58. package/dist/screenplay/RemotionRenderer/theme/themes/rightslide/Nametag.js +2 -6
  59. package/dist/screenplay/RemotionRenderer/theme/themes/sports/Nametag.js +2 -3
  60. package/dist/screenplay/RemotionRenderer/theme/themes/sports/SportsCaption.js +2 -3
  61. package/dist/screenplay/RemotionRenderer/theme/themes/sports/SportsSentence.js +2 -3
  62. package/dist/screenplay/RemotionRenderer/theme/themes/sports/Title.js +2 -3
  63. package/dist/screenplay/RemotionRenderer/theme/themes/sportsbounce/Nametag.js +2 -3
  64. package/dist/screenplay/RemotionRenderer/theme/themes/sportsbounce/SportsBounceSentence.js +2 -3
  65. package/dist/screenplay/RemotionRenderer/theme/themes/sportsbounce/Title.js +2 -3
  66. package/dist/screenplay/RemotionRenderer/theme/themes/stackfill/Nametag.js +2 -6
  67. package/dist/screenplay/RemotionRenderer/tracks/DynamicVideoComposition.js +2 -0
  68. package/dist/screenplay/RemotionRenderer/tracks/LayoutVideoTrack.js +20 -20
  69. package/package.json +49 -49
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["src", "faceMetadata", "containerWidth", "containerHeight", "enableInterpolation", "useAveragePosition", "centerHorizontally", "translateX", "translateY", "showDebugInfo", "style", "className", "containerStyle", "noBackgroundVideoEffects", "noBackgroundEffects", "transparent"];
2
+ var _excluded = ["src", "faceMetadata", "containerWidth", "containerHeight", "enableInterpolation", "useAveragePosition", "centerHorizontally", "anchorToBottom", "translateX", "translateY", "showDebugInfo", "style", "className", "containerStyle", "noBackgroundVideoEffects", "noBackgroundEffects", "transparent"];
3
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -8,34 +8,35 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
8
8
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
9
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
10
10
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
11
- /**
12
- * Face-Centered Video Component
13
- *
14
- * A reusable component that wraps OffthreadVideo to ensure the video is always
15
- * centered on a person's face within a flexible container.
16
- *
17
- * The video maintains its source dimensions and is positioned using translateX/translateY
18
- * to center the face within the container, regardless of container size.
11
+ /**
12
+ * Face-Centered Video Component
13
+ *
14
+ * A reusable component that wraps OffthreadVideo to ensure the video is always
15
+ * centered on a person's face within a flexible container.
16
+ *
17
+ * The video maintains its source dimensions and is positioned using translateX/translateY
18
+ * to center the face within the container, regardless of container size.
19
19
  */
20
20
 
21
21
  import React from "react";
22
22
  import { OffthreadVideo, useCurrentFrame } from "remotion";
23
23
  import { useOrientationBased } from "../../hooks/useOrientationBased.js";
24
24
 
25
- /**
26
- * Calculate face-centered translation for flexible container
27
- * @param {Object} params - Configuration object
28
- * @param {Object} params.faceMetadata - Face detection metadata
29
- * @param {number} params.containerWidth - Container width in pixels
30
- * @param {number} params.containerHeight - Container height in pixels
31
- * @param {number} params.currentFrame - Current frame number (optional)
32
- * @param {boolean} params.enableInterpolation - Whether to interpolate between frames
33
- * @param {boolean} params.useAveragePosition - Whether to use average face position
34
- * @param {boolean} params.centerHorizontally - Whether to only center horizontally
35
- * @param {number} params.translateX - Additional translateX offset
36
- * @param {number} params.translateY - Additional translateY offset
37
- * @param {string} params.orientation - Viewport orientation (portrait, square, landscape)
38
- * @returns {Object} Transform styles and debug info
25
+ /**
26
+ * Calculate face-centered translation for flexible container
27
+ * @param {Object} params - Configuration object
28
+ * @param {Object} params.faceMetadata - Face detection metadata
29
+ * @param {number} params.containerWidth - Container width in pixels
30
+ * @param {number} params.containerHeight - Container height in pixels
31
+ * @param {number} params.currentFrame - Current frame number (optional)
32
+ * @param {boolean} params.enableInterpolation - Whether to interpolate between frames
33
+ * @param {boolean} params.useAveragePosition - Whether to use average face position
34
+ * @param {boolean} params.centerHorizontally - Whether to only center horizontally
35
+ * @param {boolean} params.anchorToBottom - Whether to anchor the video to the container bottom edge
36
+ * @param {number} params.translateX - Additional translateX offset
37
+ * @param {number} params.translateY - Additional translateY offset
38
+ * @param {string} params.orientation - Viewport orientation (portrait, square, landscape)
39
+ * @returns {Object} Transform styles and debug info
39
40
  */
40
41
  var calculateFaceCenteredTranslation = function calculateFaceCenteredTranslation(_ref) {
41
42
  var _faceMetadata$metadat, _faceMetadata$metadat2;
@@ -50,6 +51,8 @@ var calculateFaceCenteredTranslation = function calculateFaceCenteredTranslation
50
51
  useAveragePosition = _ref$useAveragePositi === void 0 ? false : _ref$useAveragePositi,
51
52
  _ref$centerHorizontal = _ref.centerHorizontally,
52
53
  centerHorizontally = _ref$centerHorizontal === void 0 ? false : _ref$centerHorizontal,
54
+ _ref$anchorToBottom = _ref.anchorToBottom,
55
+ anchorToBottom = _ref$anchorToBottom === void 0 ? false : _ref$anchorToBottom,
53
56
  _ref$translateX = _ref.translateX,
54
57
  translateX = _ref$translateX === void 0 ? 0 : _ref$translateX,
55
58
  _ref$translateY = _ref.translateY,
@@ -120,17 +123,18 @@ var calculateFaceCenteredTranslation = function calculateFaceCenteredTranslation
120
123
  }
121
124
  }
122
125
 
123
- // Calculate translation needed to center the face in the container
124
- // When scale > 1, translate happens in scaled coordinate system, so we need to adjust
126
+ // Calculate translation needed to center the face in the container or anchor
127
+ // the source video bottom edge to the container bottom edge.
128
+ // When scale > 1, translate happens in scaled coordinate system, so we need to adjust.
125
129
  var baseTranslateX = containerCenterX - faceX + translateX;
126
- var baseTranslateY = centerHorizontally ? translateY : containerCenterY - faceY + translateY;
130
+ var baseTranslateY = anchorToBottom ? containerHeight - sourceHeight + translateY : centerHorizontally ? translateY : containerCenterY - faceY + translateY;
127
131
 
128
132
  // Adjust translation for scaling - divide by scale factor when scale > 1
129
133
  var finalTranslateX = scale > 1 ? baseTranslateX / scale : baseTranslateX;
130
134
  var finalTranslateY = scale > 1 ? baseTranslateY / scale : baseTranslateY;
131
135
 
132
136
  // Add additional translateY adjustment when scale > 1 to keep video contained within container
133
- if (!centerHorizontally) {
137
+ if (!centerHorizontally && !anchorToBottom) {
134
138
  // Calculate the scaled video height
135
139
  var scaledVideoHeight = sourceHeight * scale;
136
140
 
@@ -185,7 +189,7 @@ var calculateFaceCenteredTranslation = function calculateFaceCenteredTranslation
185
189
 
186
190
  // Transform origin should be at the face position for proper scaling
187
191
  var transformOriginX = (relativeFaceX * 100).toFixed(2);
188
- var transformOriginY = (relativeFaceY * 100).toFixed(2);
192
+ var transformOriginY = anchorToBottom ? "100.00" : (relativeFaceY * 100).toFixed(2);
189
193
  var transformOrigin = "".concat(transformOriginX, "% ").concat(transformOriginY, "%");
190
194
  return {
191
195
  transform: transform,
@@ -208,14 +212,15 @@ var calculateFaceCenteredTranslation = function calculateFaceCenteredTranslation
208
212
  containerHeight: containerHeight,
209
213
  useAveragePosition: useAveragePosition,
210
214
  centerHorizontally: centerHorizontally,
215
+ anchorToBottom: anchorToBottom,
211
216
  scalingApplied: scale > 1,
212
217
  orientation: orientation
213
218
  }
214
219
  };
215
220
  };
216
221
 
217
- /**
218
- * Get face data for a specific frame with optional interpolation
222
+ /**
223
+ * Get face data for a specific frame with optional interpolation
219
224
  */
220
225
  function getFaceDataForFrame(frames, frameIndex, enableInterpolation) {
221
226
  var _prevFrame, _nextFrame;
@@ -274,8 +279,8 @@ function getFaceDataForFrame(frames, frameIndex, enableInterpolation) {
274
279
  return ((_prevFrame = prevFrame) === null || _prevFrame === void 0 ? void 0 : _prevFrame.data) || ((_nextFrame = nextFrame) === null || _nextFrame === void 0 ? void 0 : _nextFrame.data) || null;
275
280
  }
276
281
 
277
- /**
278
- * Calculate average face position from all frames with face data
282
+ /**
283
+ * Calculate average face position from all frames with face data
279
284
  */
280
285
  function getAverageFaceData(frames) {
281
286
  if (!frames || frames.length === 0) return null;
@@ -310,14 +315,14 @@ function getAverageFaceData(frames) {
310
315
  };
311
316
  }
312
317
 
313
- /**
314
- * Calculate the negative space offset when face-centering a video
315
- *
316
- * @param {Object} faceMetadata - Face detection metadata object
317
- * @param {number} containerWidth - Container width in pixels
318
- * @param {number} containerHeight - Container height in pixels
319
- * @param {number} scale - Scale factor applied to the video
320
- * @returns {Object} Object containing horizontal and vertical offsets and which side has negative space
318
+ /**
319
+ * Calculate the negative space offset when face-centering a video
320
+ *
321
+ * @param {Object} faceMetadata - Face detection metadata object
322
+ * @param {number} containerWidth - Container width in pixels
323
+ * @param {number} containerHeight - Container height in pixels
324
+ * @param {number} scale - Scale factor applied to the video
325
+ * @returns {Object} Object containing horizontal and vertical offsets and which side has negative space
321
326
  */
322
327
  export var calculateNegativeSpaceOffset = function calculateNegativeSpaceOffset(faceMetadata, containerWidth, containerHeight) {
323
328
  var _faceMetadata$metadat4, _faceMetadata$metadat5;
@@ -415,22 +420,23 @@ export var calculateNegativeSpaceOffset = function calculateNegativeSpaceOffset(
415
420
  };
416
421
  };
417
422
 
418
- /**
419
- * FaceCenteredVideo Component
420
- * @param {Object} props - Component props
421
- * @param {string} props.src - Video source URL
422
- * @param {Object} props.faceMetadata - Face detection metadata
423
- * @param {number} props.containerWidth - Container width in pixels (required)
424
- * @param {number} props.containerHeight - Container height in pixels (required)
425
- * @param {boolean} props.enableInterpolation - Whether to interpolate between frames
426
- * @param {boolean} props.useAveragePosition - Whether to use average face position for entire video duration
427
- * @param {boolean} props.centerHorizontally - Whether to only center horizontally (X axis), not vertically (Y axis)
428
- * @param {number} props.translateX - Additional translateX offset (optional)
429
- * @param {number} props.translateY - Additional translateY offset (optional)
430
- * @param {boolean} props.showDebugInfo - Whether to show debug information
431
- * @param {Object} props.style - Additional styles to apply to video
432
- * @param {string} props.className - CSS class name
433
- * @param {...Object} props.otherProps - Other props to pass to OffthreadVideo
423
+ /**
424
+ * FaceCenteredVideo Component
425
+ * @param {Object} props - Component props
426
+ * @param {string} props.src - Video source URL
427
+ * @param {Object} props.faceMetadata - Face detection metadata
428
+ * @param {number} props.containerWidth - Container width in pixels (required)
429
+ * @param {number} props.containerHeight - Container height in pixels (required)
430
+ * @param {boolean} props.enableInterpolation - Whether to interpolate between frames
431
+ * @param {boolean} props.useAveragePosition - Whether to use average face position for entire video duration
432
+ * @param {boolean} props.centerHorizontally - Whether to only center horizontally (X axis), not vertically (Y axis)
433
+ * @param {boolean} props.anchorToBottom - Whether to anchor the video to the container bottom edge
434
+ * @param {number} props.translateX - Additional translateX offset (optional)
435
+ * @param {number} props.translateY - Additional translateY offset (optional)
436
+ * @param {boolean} props.showDebugInfo - Whether to show debug information
437
+ * @param {Object} props.style - Additional styles to apply to video
438
+ * @param {string} props.className - CSS class name
439
+ * @param {...Object} props.otherProps - Other props to pass to OffthreadVideo
434
440
  */
435
441
  export var FaceCenteredVideo = function FaceCenteredVideo(_ref2) {
436
442
  var _faceMetadata$metadat7, _faceMetadata$metadat8, _faceMetadata$metadat9, _faceMetadata$metadat10;
@@ -444,6 +450,8 @@ export var FaceCenteredVideo = function FaceCenteredVideo(_ref2) {
444
450
  useAveragePosition = _ref2$useAveragePosit === void 0 ? true : _ref2$useAveragePosit,
445
451
  _ref2$centerHorizonta = _ref2.centerHorizontally,
446
452
  centerHorizontally = _ref2$centerHorizonta === void 0 ? false : _ref2$centerHorizonta,
453
+ _ref2$anchorToBottom = _ref2.anchorToBottom,
454
+ anchorToBottom = _ref2$anchorToBottom === void 0 ? false : _ref2$anchorToBottom,
447
455
  _ref2$translateX = _ref2.translateX,
448
456
  translateX = _ref2$translateX === void 0 ? 0 : _ref2$translateX,
449
457
  _ref2$translateY = _ref2.translateY,
@@ -482,6 +490,7 @@ export var FaceCenteredVideo = function FaceCenteredVideo(_ref2) {
482
490
  enableInterpolation: enableInterpolation,
483
491
  useAveragePosition: useAveragePosition,
484
492
  centerHorizontally: centerHorizontally,
493
+ anchorToBottom: anchorToBottom,
485
494
  translateX: translateX,
486
495
  translateY: translateY,
487
496
  orientation: orientation
@@ -492,7 +501,7 @@ export var FaceCenteredVideo = function FaceCenteredVideo(_ref2) {
492
501
  var videoStyle = _objectSpread({
493
502
  width: sourceWidth || "100%",
494
503
  height: sourceHeight || "100%",
495
- transform: sourceHeight === containerHeight && sourceWidth === containerWidth ? undefined : transform,
504
+ transform: !anchorToBottom && sourceHeight === containerHeight && sourceWidth === containerWidth ? undefined : transform,
496
505
  transformOrigin: transformOrigin || "center center",
497
506
  position: "absolute",
498
507
  top: 0,
@@ -15,10 +15,10 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
15
15
  import React, { useEffect, useState } from "react";
16
16
  import { Img, delayRender, continueRender } from "remotion";
17
17
 
18
- /**
19
- * PausableImg component that extends Remotion's Img with fetch validation.
20
- * It delays rendering until the image source can be successfully fetched.
21
- * If there's an error fetching the image, it renders nothing.
18
+ /**
19
+ * PausableImg component that extends Remotion's Img with fetch validation.
20
+ * It delays rendering until the image source can be successfully fetched.
21
+ * If there's an error fetching the image, it renders nothing.
22
22
  */
23
23
  export var PausableImg = /*#__PURE__*/React.memo(function (_ref) {
24
24
  var src = _ref.src,
@@ -1,80 +1,80 @@
1
- # StretchText Component
2
-
3
- A React component that renders text that stretches to fit the parent's width. Words with fewer characters will have a larger font size than words with more characters. The component uses SVG for rendering text, which ensures proper text-stroke rendering in headless mode.
4
-
5
- ## Usage
6
-
7
- ```jsx
8
- import StretchText from './StretchText';
9
-
10
- // Basic usage
11
- <StretchText text="Hello World" />
12
-
13
- // With custom styling
14
- <StretchText
15
- text="Contribution"
16
- color="#1a73e8"
17
- fontFamily="Arial"
18
- maxFontSize={200}
19
- minFontSize={10}
20
- style={{ fontWeight: 'bold' }}
21
- />
22
-
23
- // With text stroke
24
- <StretchText
25
- text="Outlined Text"
26
- color="transparent"
27
- textStrokeColor="white"
28
- textStrokeWidth="2px"
29
- style={{ fontWeight: 'bold' }}
30
- />
31
- ```
32
-
33
- ## Props
34
-
35
- | Prop | Type | Default | Description |
36
- |------|------|---------|-------------|
37
- | `text` | string | required | The text to display |
38
- | `color` | string | '#000000' | Text color |
39
- | `fontFamily` | string | 'Arial' | Font family |
40
- | `maxFontSize` | number | 100 | Maximum font size in pixels |
41
- | `minFontSize` | number | 10 | Minimum font size in pixels |
42
- | `textStrokeColor` | string | undefined | Color of the text stroke |
43
- | `textStrokeWidth` | string | undefined | Width of the text stroke (e.g., '2px') |
44
- | `textFillColor` | string | undefined | Color of the text fill (overrides `color` if provided) |
45
- | `style` | object | {} | Additional style properties |
46
-
47
- ## Examples
48
-
49
- The component automatically calculates the appropriate font size to make the text stretch to fit the parent width. For example:
50
-
51
- - "Work" (4 characters) will have a larger font size than "Contribution" (12 characters) when both are rendered in containers of the same width.
52
- - The text will always be contained within the parent container and will not overflow.
53
- - The component recalculates the font size when the window is resized.
54
-
55
- ## Demo
56
-
57
- You can see a demo of the StretchText component by running the development environment and looking at the first segment in the video timeline.
58
-
59
- The demo shows several words of different lengths rendered in containers of the same width:
60
-
61
- - "Contribution" (longer word, smaller font)
62
- - "Work" (shorter word, larger font)
63
- - "Hello" (medium length word, medium font)
64
- - "Supercalifragilisticexpialidocious" (very long word, very small font)
65
-
66
- Each word stretches to fill the entire width of its container, demonstrating how the component automatically adjusts the font size based on the text length.
67
-
68
- ## Implementation Details
69
-
70
- The component uses a binary search algorithm to find the optimal font size that makes the text fit the parent width. It uses a simple approximation for text width calculation (character count * fontSize * 0.75) which works well for most fonts.
71
-
72
- The component uses SVG for rendering text, which provides several advantages:
73
- - Proper text-stroke rendering in headless mode
74
- - Better control over text positioning and alignment
75
- - Consistent rendering across different browsers and environments
76
- - Support for advanced SVG features like filters for text shadows
77
-
78
- For text with stroke effects, the component uses SVG's native stroke and fill attributes, which are more reliable than CSS text-stroke properties, especially in headless rendering environments.
79
-
80
- The component also includes a resize listener to recalculate the font size when the window size changes.
1
+ # StretchText Component
2
+
3
+ A React component that renders text that stretches to fit the parent's width. Words with fewer characters will have a larger font size than words with more characters. The component uses SVG for rendering text, which ensures proper text-stroke rendering in headless mode.
4
+
5
+ ## Usage
6
+
7
+ ```jsx
8
+ import StretchText from './StretchText';
9
+
10
+ // Basic usage
11
+ <StretchText text="Hello World" />
12
+
13
+ // With custom styling
14
+ <StretchText
15
+ text="Contribution"
16
+ color="#1a73e8"
17
+ fontFamily="Arial"
18
+ maxFontSize={200}
19
+ minFontSize={10}
20
+ style={{ fontWeight: 'bold' }}
21
+ />
22
+
23
+ // With text stroke
24
+ <StretchText
25
+ text="Outlined Text"
26
+ color="transparent"
27
+ textStrokeColor="white"
28
+ textStrokeWidth="2px"
29
+ style={{ fontWeight: 'bold' }}
30
+ />
31
+ ```
32
+
33
+ ## Props
34
+
35
+ | Prop | Type | Default | Description |
36
+ |------|------|---------|-------------|
37
+ | `text` | string | required | The text to display |
38
+ | `color` | string | '#000000' | Text color |
39
+ | `fontFamily` | string | 'Arial' | Font family |
40
+ | `maxFontSize` | number | 100 | Maximum font size in pixels |
41
+ | `minFontSize` | number | 10 | Minimum font size in pixels |
42
+ | `textStrokeColor` | string | undefined | Color of the text stroke |
43
+ | `textStrokeWidth` | string | undefined | Width of the text stroke (e.g., '2px') |
44
+ | `textFillColor` | string | undefined | Color of the text fill (overrides `color` if provided) |
45
+ | `style` | object | {} | Additional style properties |
46
+
47
+ ## Examples
48
+
49
+ The component automatically calculates the appropriate font size to make the text stretch to fit the parent width. For example:
50
+
51
+ - "Work" (4 characters) will have a larger font size than "Contribution" (12 characters) when both are rendered in containers of the same width.
52
+ - The text will always be contained within the parent container and will not overflow.
53
+ - The component recalculates the font size when the window is resized.
54
+
55
+ ## Demo
56
+
57
+ You can see a demo of the StretchText component by running the development environment and looking at the first segment in the video timeline.
58
+
59
+ The demo shows several words of different lengths rendered in containers of the same width:
60
+
61
+ - "Contribution" (longer word, smaller font)
62
+ - "Work" (shorter word, larger font)
63
+ - "Hello" (medium length word, medium font)
64
+ - "Supercalifragilisticexpialidocious" (very long word, very small font)
65
+
66
+ Each word stretches to fill the entire width of its container, demonstrating how the component automatically adjusts the font size based on the text length.
67
+
68
+ ## Implementation Details
69
+
70
+ The component uses a binary search algorithm to find the optimal font size that makes the text fit the parent width. It uses a simple approximation for text width calculation (character count * fontSize * 0.75) which works well for most fonts.
71
+
72
+ The component uses SVG for rendering text, which provides several advantages:
73
+ - Proper text-stroke rendering in headless mode
74
+ - Better control over text positioning and alignment
75
+ - Consistent rendering across different browsers and environments
76
+ - Support for advanced SVG features like filters for text shadows
77
+
78
+ For text with stroke effects, the component uses SVG's native stroke and fill attributes, which are more reliable than CSS text-stroke properties, especially in headless rendering environments.
79
+
80
+ The component also includes a resize listener to recalculate the font size when the window size changes.
@@ -2,9 +2,9 @@ import React from "react";
2
2
  import { AbsoluteFill } from "remotion";
3
3
  import StretchText from "./StretchText";
4
4
 
5
- /**
6
- * Demo component to showcase the StretchText component
7
- * Shows how different words stretch to the same width with different font sizes
5
+ /**
6
+ * Demo component to showcase the StretchText component
7
+ * Shows how different words stretch to the same width with different font sizes
8
8
  */
9
9
  var StretchTextDemo = function StretchTextDemo() {
10
10
  var containerStyle = {