🎥 Make videos programmatically with React
Update parse-linear-gradient.ts
Jonny Burgerf1f695631738
diff --git a/packages/web-renderer/src/drawing/parse-linear-gradient.ts b/packages/web-renderer/src/drawing/parse-linear-gradient.tsindex 95b8bae4e3..3a2b8f4538 100644--- a/packages/web-renderer/src/drawing/parse-linear-gradient.ts+++ b/packages/web-renderer/src/drawing/parse-linear-gradient.ts@@ -101,7 +101,9 @@ const parseColorStops = (colorStopsStr: string): ColorStop[] | null => {continue;}- const remaining = trimmed.substring(colorMatch.index! + colorStr.length).trim();+ const remaining = trimmed+ .substring(colorMatch.index! + colorStr.length)+ .trim();// Canvas API supports CSS colors directly, so we can use the color string as-isconst normalizedColor = colorStr;@@ -180,15 +182,11 @@ const parseColorStops = (colorStopsStr: string): ColorStop[] | null => {stops[i].position = i / (stops.length - 1);}}- } else {- // Handle trailing stops without explicit positions- if (lastExplicitIndex < stops.length - 1) {- const numImplicit = stops.length - 1 - lastExplicitIndex;- const step = (1 - lastExplicitPosition) / (numImplicit + 1);- for (let i = lastExplicitIndex + 1; i < stops.length; i++) {- stops[i].position =- lastExplicitPosition + step * (i - lastExplicitIndex);- }+ } else if (lastExplicitIndex < stops.length - 1) {+ const numImplicit = stops.length - 1 - lastExplicitIndex;+ const step = (1 - lastExplicitPosition) / (numImplicit + 1);+ for (let i = lastExplicitIndex + 1; i < stops.length; i++) {+ stops[i].position = lastExplicitPosition + step * (i - lastExplicitIndex);}}@@ -209,7 +207,7 @@ const extractGradientContent = (backgroundImage: string): string | null => {// Find matching closing parenthesis, handling nested parens from rgb(), rgba(), etc.let depth = 0;- let contentStart = startIndex + prefix.length;+ const contentStart = startIndex + prefix.length;for (let i = contentStart; i < backgroundImage.length; i++) {const char = backgroundImage[i];if (char === '(') {@@ -218,6 +216,7 @@ const extractGradientContent = (backgroundImage: string): string | null => {if (depth === 0) {return backgroundImage.substring(contentStart, i).trim();}+depth--;}}