Skip to content

🎥 Make videos programmatically with React

nice, good

JonnyBurger5015d2e72b36
diff --git a/bun.lock b/bun.lock
index d1609c5759..6aed60584d 100644
--- a/bun.lock
+++ b/bun.lock
@@ -550,6 +550,7 @@
"@remotion/preload": "workspace:*",
"@remotion/renderer": "workspace:*",
"@remotion/rive": "workspace:*",
+ "@remotion/rounded-text-box": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/skia": "workspace:*",
"@remotion/studio": "workspace:*",
@@ -3669,7 +3670,7 @@
"@types/estree-jsx": ["@types/[email protected]", "", { "dependencies": { "@types/estree": "1.0.7" } }, "sha512-3qvGd0z8F2ENTGr/GG1yViqfiKmRfrXVx5sJyHGFu3z7m5g5utCQtGp/g29JnjflhtQJBv1WDQukHiT58xPcYQ=="],
- "@types/express": ["@types/[email protected]", "", { "dependencies": { "@types/body-parser": "1.19.1", "@types/express-serve-static-core": "4.17.35", "@types/qs": "6.9.7", "@types/serve-static": "1.13.10" } }, "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA=="],
+ "@types/express": ["@types/[email protected]", "", { "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", "@types/qs": "*", "@types/serve-static": "*" } }, "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ=="],
"@types/express-rate-limit": ["@types/[email protected]", "", { "dependencies": { "@types/express": "5.0.1" } }, "sha512-H+TYy3K53uPU2TqPGFYaiWc2xJV6+bIFkDd/Ma2/h67Pa6ARk9kWE0p/K9OH1Okm0et9Sfm66fmXoAxsH2PHXg=="],
@@ -3789,7 +3790,7 @@
"@types/serve-index": ["@types/[email protected]", "", { "dependencies": { "@types/express": "*" } }, "sha512-qLpGZ/c2fhSs5gnYsQxtDEq3Oy8SXPClIXkW5ghvAvsNuVSA8k+gCONcUCS/UjLEYvYps+e8uBtfgXgvhwfNug=="],
- "@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+ "@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/http-errors": "*", "@types/node": "*", "@types/send": "<1" } }, "sha512-dOTIuqpWLyl3BBXU3maNQsS4A3zuuoYRNIvYSxxhebPfXg2mzWQEPne/nlJ37yOse6uGgR386uTpdsx4D0QZWA=="],
"@types/sharp": ["@types/[email protected]", "", { "dependencies": { "@types/node": "20.12.14" } }, "sha512-AjKjo5vk5mkcTrWL0U1zFUdCp/uqLebvbe7ezAJx0tgp6ST9JmfsYK1q1lpjfPM5S1YQ1wr5uboPSu2S8UO9yw=="],
@@ -8865,8 +8866,12 @@
"template-render-server/express": ["[email protected]", "", { "dependencies": { "accepts": "2.0.0", "body-parser": "2.2.0", "content-disposition": "1.0.0", "content-type": "1.0.5", "cookie": "0.7.2", "cookie-signature": "1.2.1", "debug": "4.4.0", "encodeurl": "2.0.0", "escape-html": "1.0.3", "etag": "1.8.1", "finalhandler": "2.1.0", "fresh": "2.0.0", "http-errors": "2.0.0", "merge-descriptors": "2.0.0", "mime-types": "3.0.1", "on-finished": "2.4.1", "once": "1.4.0", "parseurl": "1.3.3", "proxy-addr": "2.0.7", "qs": "6.14.0", "range-parser": "1.2.1", "router": "2.2.0", "send": "1.2.0", "serve-static": "2.2.0", "statuses": "2.0.1", "type-is": "2.0.1", "vary": "1.1.2" } }, "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA=="],
+ "template-still/@types/express": ["@types/[email protected]", "", { "dependencies": { "@types/body-parser": "1.19.1", "@types/express-serve-static-core": "4.17.35", "@types/qs": "6.9.7", "@types/serve-static": "1.13.10" } }, "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA=="],
+
"template-still/dotenv": ["[email protected]", "", {}, "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="],
+ "template-tts-google/@types/express": ["@types/[email protected]", "", { "dependencies": { "@types/body-parser": "1.19.1", "@types/express-serve-static-core": "4.17.35", "@types/qs": "6.9.7", "@types/serve-static": "1.13.10" } }, "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA=="],
+
"template-tts-google/dotenv": ["[email protected]", "", {}, "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="],
"terser/acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA=="],
@@ -8985,10 +8990,6 @@
"webpack-dev-middleware/schema-utils": ["[email protected]", "", { "dependencies": { "@types/json-schema": "7.0.15", "ajv": "8.11.0", "ajv-formats": "2.1.1", "ajv-keywords": "5.1.0" } }, "sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw=="],
- "webpack-dev-server/@types/express": ["@types/[email protected]", "", { "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", "@types/qs": "*", "@types/serve-static": "*" } }, "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ=="],
-
- "webpack-dev-server/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/http-errors": "*", "@types/node": "*", "@types/send": "<1" } }, "sha512-dOTIuqpWLyl3BBXU3maNQsS4A3zuuoYRNIvYSxxhebPfXg2mzWQEPne/nlJ37yOse6uGgR386uTpdsx4D0QZWA=="],
-
"webpack-dev-server/chokidar": ["[email protected]", "", { "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw=="],
"webpack-dev-server/express": ["[email protected]", "", { "dependencies": { "accepts": "1.3.8", "array-flatten": "1.1.1", "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "1.0.5", "cookie": "0.7.1", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", "encodeurl": "2.0.0", "escape-html": "1.0.3", "etag": "1.8.1", "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", "merge-descriptors": "1.0.3", "methods": "1.1.2", "on-finished": "2.4.1", "parseurl": "1.3.3", "path-to-regexp": "0.1.12", "proxy-addr": "2.0.7", "qs": "6.13.0", "range-parser": "1.2.1", "safe-buffer": "5.2.1", "send": "0.19.0", "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "1.6.18", "utils-merge": "1.0.1", "vary": "1.1.2" } }, "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA=="],
@@ -9537,6 +9538,8 @@
"@google-cloud/functions-framework/@types/express/@types/express-serve-static-core": ["@types/[email protected]", "", { "dependencies": { "@types/node": "20.12.14", "@types/qs": "6.9.7", "@types/range-parser": "1.2.4", "@types/send": "0.17.1" } }, "sha512-5kz9ScmzBdzTgB/3susoCgfqNDzBjvLL4taparufgSvlwjdLy6UyUy9T/tCpYd2GIdIilCatC4iSQS0QSYHt0w=="],
+ "@google-cloud/functions-framework/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+
"@google-cloud/functions-framework/express/cookie": ["[email protected]", "", {}, "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w=="],
"@google-cloud/functions-framework/express/cookie-signature": ["[email protected]", "", {}, "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="],
@@ -9699,8 +9702,12 @@
"@remotion/lambda-client/@types/express/@types/express-serve-static-core": ["@types/[email protected]", "", { "dependencies": { "@types/node": "20.12.14", "@types/qs": "6.9.7", "@types/range-parser": "1.2.4", "@types/send": "0.17.1" } }, "sha512-5kz9ScmzBdzTgB/3susoCgfqNDzBjvLL4taparufgSvlwjdLy6UyUy9T/tCpYd2GIdIilCatC4iSQS0QSYHt0w=="],
+ "@remotion/lambda-client/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+
"@remotion/lambda/@types/express/@types/express-serve-static-core": ["@types/[email protected]", "", { "dependencies": { "@types/node": "20.12.14", "@types/qs": "6.9.7", "@types/range-parser": "1.2.4", "@types/send": "0.17.1" } }, "sha512-5kz9ScmzBdzTgB/3susoCgfqNDzBjvLL4taparufgSvlwjdLy6UyUy9T/tCpYd2GIdIilCatC4iSQS0QSYHt0w=="],
+ "@remotion/lambda/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+
"@remotion/media/vitest/@types/chai": ["@types/[email protected]", "", { "dependencies": { "@types/deep-eql": "4.0.2" } }, "sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg=="],
"@remotion/media/vitest/@vitest/expect": ["@vitest/[email protected]", "", { "dependencies": { "@types/chai": "5.2.2", "@vitest/spy": "3.2.4", "@vitest/utils": "3.2.4", "chai": "5.3.3", "tinyrainbow": "2.0.0" } }, "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig=="],
@@ -9905,8 +9912,12 @@
"@types/express-rate-limit/@types/express/@types/express-serve-static-core": ["@types/[email protected]", "", { "dependencies": { "@types/node": "20.12.14", "@types/qs": "6.9.7", "@types/range-parser": "1.2.4", "@types/send": "0.17.1" } }, "sha512-5kz9ScmzBdzTgB/3susoCgfqNDzBjvLL4taparufgSvlwjdLy6UyUy9T/tCpYd2GIdIilCatC4iSQS0QSYHt0w=="],
+ "@types/express-rate-limit/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+
"@types/serve-index/@types/express/@types/express-serve-static-core": ["@types/[email protected]", "", { "dependencies": { "@types/node": "20.12.14", "@types/qs": "6.9.7", "@types/range-parser": "1.2.4", "@types/send": "0.17.1" } }, "sha512-5kz9ScmzBdzTgB/3susoCgfqNDzBjvLL4taparufgSvlwjdLy6UyUy9T/tCpYd2GIdIilCatC4iSQS0QSYHt0w=="],
+ "@types/serve-index/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+
"@typescript-eslint/type-utils/@typescript-eslint/utils/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A=="],
"@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["[email protected]", "", { "dependencies": { "balanced-match": "1.0.2" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
@@ -10641,6 +10652,8 @@
"template-render-server/@types/express/@types/express-serve-static-core": ["@types/[email protected]", "", { "dependencies": { "@types/node": "20.12.14", "@types/qs": "6.9.7", "@types/range-parser": "1.2.4", "@types/send": "0.17.1" } }, "sha512-5kz9ScmzBdzTgB/3susoCgfqNDzBjvLL4taparufgSvlwjdLy6UyUy9T/tCpYd2GIdIilCatC4iSQS0QSYHt0w=="],
+ "template-render-server/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+
"template-render-server/express/accepts": ["[email protected]", "", { "dependencies": { "mime-types": "3.0.1", "negotiator": "1.0.0" } }, "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng=="],
"template-render-server/express/body-parser": ["[email protected]", "", { "dependencies": { "bytes": "3.1.2", "content-type": "1.0.5", "debug": "4.4.1", "http-errors": "2.0.0", "iconv-lite": "0.6.3", "on-finished": "2.4.1", "qs": "6.14.0", "raw-body": "3.0.0", "type-is": "2.0.1" } }, "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg=="],
@@ -10665,6 +10678,10 @@
"template-render-server/express/type-is": ["[email protected]", "", { "dependencies": { "content-type": "1.0.5", "media-typer": "1.1.0", "mime-types": "3.0.1" } }, "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw=="],
+ "template-still/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+
+ "template-tts-google/@types/express/@types/serve-static": ["@types/[email protected]", "", { "dependencies": { "@types/mime": "1.3.2", "@types/node": "20.12.14" } }, "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ=="],
+
"terser-webpack-plugin/@swc/core/@swc/core-darwin-arm64": ["@swc/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-TIus1/SE/Ud4g84hCnchcagu+LfyndSDy5r5qf64nflojejDidPU9Fp1InzQhQpEgIpntnZID/KFCP5rQnvsIw=="],
"terser-webpack-plugin/@swc/core/@swc/core-darwin-x64": ["@swc/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-yCb1FHCX/HUmNRGB1X3CFJ1WPKXMosZVUe3K2TrosCGvytwgaLoW5FS0bZg5Qv6cEUERQBg75cJnOUPwLLRCVg=="],
diff --git a/packages/example/package.json b/packages/example/package.json
index 2ee889333c..02ba4a902d 100644
--- a/packages/example/package.json
+++ b/packages/example/package.json
@@ -57,6 +57,7 @@
"@remotion/player": "workspace:*",
"@remotion/preload": "workspace:*",
"@remotion/renderer": "workspace:*",
+ "@remotion/rounded-text-box": "workspace:*",
"@remotion/rive": "workspace:*",
"@remotion/shapes": "workspace:*",
"@remotion/skia": "workspace:*",
diff --git a/packages/example/src/TikTokTextbox/TikTokTextBox.tsx b/packages/example/src/TikTokTextbox/TikTokTextBox.tsx
index 99bd18c28e..45e304da3f 100644
--- a/packages/example/src/TikTokTextbox/TikTokTextBox.tsx
+++ b/packages/example/src/TikTokTextbox/TikTokTextBox.tsx
@@ -5,7 +5,7 @@
import {measureText} from '@remotion/layout-utils';
import {getBoundingBox} from '@remotion/paths';
-import {createRoundedTextBox} from './svg';
+import {createRoundedTextBox} from '@remotion/rounded-text-box';
interface TikTokTextBoxProps {
lines: string[];
@@ -99,7 +99,7 @@ export const TikTokTextBox: React.FC<TikTokTextBoxProps> = ({
overflow: 'visible',
}}
>
- <path fill="white" d={svg} strokeWidth={3} />
+ <path fill="white" d={svg} />
</svg>
{lines.map((line, i) => (
diff --git a/packages/example/src/TikTokTextbox/rounded-corner.tsx b/packages/example/src/TikTokTextbox/rounded-corner.tsx
deleted file mode 100644
index 4ae450ec0d..0000000000
--- a/packages/example/src/TikTokTextbox/rounded-corner.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-type Corner = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
-
-const magicCssBorderRadiusNumber = 0.5522847682119205;
-
-export const getActualBorderRadius = ({
- desiredBorderRadius,
- widthDifference,
-}: {
- desiredBorderRadius: number;
- widthDifference: number | undefined;
-}) => {
- return (
- Math.floor(
- (widthDifference !== undefined
- ? Math.min(Math.abs(widthDifference / 2), desiredBorderRadius)
- : desiredBorderRadius) * window.devicePixelRatio,
- ) / window.devicePixelRatio
- );
-};
-
-export const getPathForCorner = ({
- corner,
- desiredBorderRadius,
- widthDifference,
-}: {
- corner: Corner;
- desiredBorderRadius: number;
- widthDifference: number | undefined;
-}) => {
- const width = getActualBorderRadius({
- desiredBorderRadius,
- widthDifference,
- });
- const borderRadius = width * 100;
-
- if (corner === 'top-left') {
- const cp1X = borderRadius - magicCssBorderRadiusNumber * borderRadius;
- const cp1Y = 0;
- const cp2X = 0;
- const cp2Y = borderRadius - magicCssBorderRadiusNumber * borderRadius;
- const d = `M 0 0 L ${borderRadius} ${0} C ${cp1X} ${cp1Y} ${cp2X} ${cp2Y} 0 ${borderRadius}`;
- return {d, borderRadius, width};
- } else if (corner === 'top-right') {
- const cp1X = borderRadius - magicCssBorderRadiusNumber * borderRadius;
- const cp1Y = 0;
- const cp2X = borderRadius;
- const cp2Y = borderRadius - magicCssBorderRadiusNumber * borderRadius;
- const d = `M ${borderRadius} 0 L 0 ${0} C ${cp1X} ${cp1Y} ${cp2X} ${cp2Y} ${borderRadius} ${borderRadius}`;
- return {d, borderRadius, width};
- } else if (corner === 'bottom-left') {
- const cp1X = 0;
- const cp1Y = borderRadius - magicCssBorderRadiusNumber * borderRadius;
- const cp2X = borderRadius - magicCssBorderRadiusNumber * borderRadius;
- const cp2Y = borderRadius;
- const d = `M 0 ${borderRadius} L 0 0 C ${cp1X} ${cp1Y} ${cp2X} ${cp2Y} ${borderRadius} ${borderRadius}`;
- return {d, borderRadius, width};
- } else if (corner === 'bottom-right') {
- const cp1X = borderRadius;
- const cp1Y = borderRadius - magicCssBorderRadiusNumber * borderRadius;
- const cp2X = borderRadius - magicCssBorderRadiusNumber * borderRadius;
- const cp2Y = borderRadius;
- const d = `M ${borderRadius} ${borderRadius} L ${borderRadius} 0 C ${cp1X} ${cp1Y} ${cp2X} ${cp2Y} 0 ${borderRadius}`;
- return {d, borderRadius, width};
- }
-
- throw new Error(`Invalid corner: ${corner}`);
-};
diff --git a/packages/example/src/TikTokTextbox/svg.ts b/packages/example/src/TikTokTextbox/svg.ts
deleted file mode 100644
index 66c5e912f2..0000000000
--- a/packages/example/src/TikTokTextbox/svg.ts
+++ /dev/null
@@ -1,244 +0,0 @@
-import {Dimensions} from '@remotion/layout-utils';
-import {Instruction, serializeInstructions} from '@remotion/paths';
-
-const clamp = (val: number, min: number, max: number) => {
- return Math.min(Math.max(val, min), max);
-};
-
-export const createRoundedTextBox = ({
- textMeasurements,
- textAlign,
- horizontalPadding,
- cornerRadius: unclampedMaxCornerRadius,
-}: {
- textMeasurements: Dimensions[];
- textAlign: 'left' | 'center' | 'right';
- horizontalPadding: number;
- cornerRadius: number;
-}) => {
- const instructions: Instruction[] = [];
-
- let maxWidth = 0;
- for (const cornerRounding of textMeasurements) {
- maxWidth = Math.max(maxWidth, cornerRounding.width + horizontalPadding * 2);
- }
-
- let yOffset = 0;
-
- for (let i = 0; i < textMeasurements.length; i++) {
- const prevCornerRounding = textMeasurements[i - 1];
- const cornerRounding = textMeasurements[i];
- const nextCornerRounding = textMeasurements[i + 1];
- let xOffset = 0;
- if (textAlign === 'center') {
- xOffset = (maxWidth - (cornerRounding.width + horizontalPadding * 2)) / 2;
- } else if (textAlign === 'right') {
- xOffset = maxWidth - (cornerRounding.width + horizontalPadding * 2);
- }
- const maxCornerRadius = clamp(
- unclampedMaxCornerRadius,
- 0,
- cornerRounding.height / 2,
- );
-
- if (i === 0) {
- instructions.push({
- type: 'M',
- x: xOffset + maxCornerRadius,
- y: yOffset,
- });
- }
-
- const topRightCornerRadius = clamp(
- prevCornerRounding
- ? textAlign === 'right'
- ? 0
- : textAlign === 'left'
- ? (prevCornerRounding.width - cornerRounding.width) / 2
- : (prevCornerRounding.width - cornerRounding.width) / 4
- : -Infinity,
- -maxCornerRadius,
- maxCornerRadius,
- );
- // Top Right Corner
- if (topRightCornerRadius !== 0) {
- instructions.push({
- type: 'L',
- x:
- xOffset +
- cornerRounding.width +
- horizontalPadding * 2 +
- topRightCornerRadius,
- y: yOffset,
- });
- // Arc for rounded corner (top right)
- instructions.push({
- type: 'A',
- rx: Math.abs(topRightCornerRadius),
- ry: Math.abs(topRightCornerRadius),
- xAxisRotation: 0,
- largeArcFlag: false,
- sweepFlag: topRightCornerRadius < 0,
- x: xOffset + cornerRounding.width + horizontalPadding * 2,
- y: yOffset + Math.abs(topRightCornerRadius),
- });
- } else {
- instructions.push({
- type: 'L',
- x: xOffset + cornerRounding.width + horizontalPadding * 2,
- y: yOffset,
- });
- }
-
- const bottomRightCornerRadius = clamp(
- nextCornerRounding
- ? textAlign === 'right'
- ? 0
- : textAlign === 'left'
- ? (nextCornerRounding.width - cornerRounding.width) / 2
- : (nextCornerRounding.width - cornerRounding.width) / 4
- : -Infinity,
- -maxCornerRadius,
- maxCornerRadius,
- );
-
- // Bottom Right Corner
- if (bottomRightCornerRadius !== 0) {
- instructions.push({
- type: 'L',
- x: xOffset + cornerRounding.width + horizontalPadding * 2,
- y: yOffset + cornerRounding.height - Math.abs(bottomRightCornerRadius),
- });
- // Arc for rounded corner (bottom right)
- instructions.push({
- type: 'A',
- rx: Math.abs(bottomRightCornerRadius),
- ry: Math.abs(bottomRightCornerRadius),
- xAxisRotation: 0,
- largeArcFlag: false,
- sweepFlag: bottomRightCornerRadius < 0,
- x:
- xOffset +
- cornerRounding.width +
- horizontalPadding * 2 +
- bottomRightCornerRadius,
- y: yOffset + cornerRounding.height,
- });
- } else {
- instructions.push({
- type: 'L',
- x: xOffset + cornerRounding.width + horizontalPadding * 2,
- y: yOffset + cornerRounding.height,
- });
- }
- yOffset += cornerRounding.height;
- }
-
- for (let i = textMeasurements.length - 1; i >= 0; i--) {
- const cornerRounding = textMeasurements[i];
- const prevCornerRounding = textMeasurements[i + 1];
- const nextCornerRounding = textMeasurements[i - 1];
- let xOffset = 0;
- if (textAlign === 'center') {
- xOffset = (maxWidth - (cornerRounding.width + horizontalPadding * 2)) / 2;
- } else if (textAlign === 'right') {
- xOffset = maxWidth - (cornerRounding.width + horizontalPadding * 2);
- }
-
- const bottomLeftWidthDifference = prevCornerRounding
- ? prevCornerRounding.width - cornerRounding.width
- : -Infinity;
-
- const maxCornerRadius = clamp(
- unclampedMaxCornerRadius,
- 0,
- cornerRounding.height / 2,
- );
-
- const bottomLeftCornerRadius = clamp(
- prevCornerRounding
- ? textAlign === 'left'
- ? 0
- : textAlign === 'right'
- ? bottomLeftWidthDifference / 2
- : bottomLeftWidthDifference / 4
- : -Infinity,
- -maxCornerRadius,
- maxCornerRadius,
- );
-
- // Bottom Left Corner
- if (bottomLeftCornerRadius !== 0) {
- instructions.push({
- type: 'L',
- x: xOffset - bottomLeftCornerRadius,
- y: yOffset,
- });
- // Arc for rounded corner (bottom left)
- instructions.push({
- type: 'A',
- rx: Math.abs(bottomLeftCornerRadius),
- ry: Math.abs(bottomLeftCornerRadius),
- xAxisRotation: 0,
- largeArcFlag: false,
- sweepFlag: bottomLeftCornerRadius < 0,
- x: xOffset,
- y: yOffset - Math.abs(bottomLeftCornerRadius),
- });
- } else {
- instructions.push({
- type: 'L',
- x: xOffset,
- y: yOffset,
- });
- }
-
- const topLeftWidthDifference = nextCornerRounding
- ? nextCornerRounding.width - cornerRounding.width
- : -Infinity;
- const topLeftCornerRadius = clamp(
- nextCornerRounding
- ? textAlign === 'left'
- ? 0
- : textAlign === 'right'
- ? topLeftWidthDifference / 2
- : topLeftWidthDifference / 4
- : -Infinity,
- -maxCornerRadius,
- maxCornerRadius,
- );
-
- // Top Left Corner
- if (topLeftCornerRadius !== 0) {
- instructions.push({
- type: 'L',
- x: xOffset,
- y: yOffset - cornerRounding.height + Math.abs(topLeftCornerRadius),
- });
- // Arc for rounded corner (top left)
- instructions.push({
- type: 'A',
- rx: Math.abs(topLeftCornerRadius),
- ry: Math.abs(topLeftCornerRadius),
- xAxisRotation: 0,
- largeArcFlag: false,
- sweepFlag: topLeftCornerRadius < 0,
- x: xOffset - topLeftCornerRadius,
- y: yOffset - cornerRounding.height,
- });
- } else {
- instructions.push({
- type: 'L',
- x: xOffset,
- y: yOffset - cornerRounding.height,
- });
- }
-
- yOffset -= cornerRounding.height;
- }
- instructions.push({
- type: 'Z',
- });
-
- return serializeInstructions(instructions);
-};