🎥 Make videos programmatically with React
`@remotion/effects`: Fix lines() and waves() categorization and preview defaults (#7945)
Jonny Burger29c932e7a0cd
diff --git a/packages/docs/components/effects/effects-lines-preview.tsx b/packages/docs/components/effects/effects-lines-preview.tsxindex d14f9d3c55..717b8fa757 100644--- a/packages/docs/components/effects/effects-lines-preview.tsx+++ b/packages/docs/components/effects/effects-lines-preview.tsx@@ -1,7 +1,6 @@import {lines} from '@remotion/effects/lines';import React from 'react';-import {CanvasImage} from 'remotion';-import {EFFECTS_PREVIEW_IMAGE_SRC} from './effects-preview-image';+import {Solid, useVideoConfig} from 'remotion';export const EffectsLinesPreview: React.FC<{readonly direction: 'horizontal' | 'vertical';@@ -10,12 +9,12 @@ export const EffectsLinesPreview: React.FC<{readonly angle: number;readonly offset: number;}> = ({direction, thickness, gap, angle, offset}) => {+ const {width, height} = useVideoConfig();+return (- <CanvasImage- src={EFFECTS_PREVIEW_IMAGE_SRC}- width={1280}- height={720}- fit="cover"+ <Solid+ width={width}+ height={height}effects={[lines({direction, thickness, gap, angle, offset})]}/>);diff --git a/packages/docs/components/effects/effects-waves-preview.tsx b/packages/docs/components/effects/effects-waves-preview.tsxindex ac0c2d6415..22f417f85e 100644--- a/packages/docs/components/effects/effects-waves-preview.tsx+++ b/packages/docs/components/effects/effects-waves-preview.tsx@@ -1,8 +1,7 @@import type {WavesDirection} from '@remotion/effects/waves';import {waves} from '@remotion/effects/waves';import React from 'react';-import {CanvasImage} from 'remotion';-import {EFFECTS_PREVIEW_IMAGE_SRC} from './effects-preview-image';+import {Solid, useVideoConfig} from 'remotion';export const EffectsWavesPreview: React.FC<{readonly direction: WavesDirection;@@ -14,12 +13,12 @@ export const EffectsWavesPreview: React.FC<{readonly wavelength: number;readonly phase: number;}> = ({direction, thickness, gap, angle, offset, amplitude, wavelength, phase}) => {+ const {width, height} = useVideoConfig();+return (- <CanvasImage- src={EFFECTS_PREVIEW_IMAGE_SRC}- width={1280}- height={720}- fit="cover"+ <Solid+ width={width}+ height={height}effects={[waves({direction,diff --git a/packages/docs/docs/effects/lines.mdx b/packages/docs/docs/effects/lines.mdxindex ba9c44a687..49f6afb8bc 100644--- a/packages/docs/docs/effects/lines.mdx+++ b/packages/docs/docs/effects/lines.mdx@@ -12,7 +12,7 @@ _Part of the [`@remotion/effects`](/docs/effects/api) package._Adds an alternating line pattern to canvas-based components such as [`<Video>`](/docs/media/video), [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas) and [`<Solid>`](/docs/solid).-Each line color is composited over the source. Transparent colors leave the source unchanged.+Each line color is composited over the source.## Preview@@ -34,7 +34,7 @@ export const MyComp: React.FC = () => {src="https://remotion.media/video.mp4"effects={[lines({- colors: ['#dff4ff', 'transparent'],+ colors: ['#dff4ff', '#7cc6ff'],direction: 'horizontal',thickness: 40,gap: 24,@@ -56,7 +56,7 @@ Pass an object with the following properties. You can also call `lines()` withouAn array of color strings for the line stripes. Colors are assigned cyclically. Must contain at least 2 colors.-Defaults to `['#dff4ff', 'transparent']`.+Defaults to `['#dff4ff', '#7cc6ff']`.### `direction?`diff --git a/packages/docs/docs/effects/table-of-contents.tsx b/packages/docs/docs/effects/table-of-contents.tsxindex ecbf9990da..e4f81f67bb 100644--- a/packages/docs/docs/effects/table-of-contents.tsx+++ b/packages/docs/docs/effects/table-of-contents.tsx@@ -196,20 +196,6 @@ const categories: {name: 'halftone()',description: 'Source-image halftone effect',},- {- link: '/docs/effects/lines',- preview: '/img/effects-lines-preview.png',- alt: 'lines effect preview',- name: 'lines()',- description: 'Alternating line overlay effect',- },- {- link: '/docs/effects/waves',- preview: '/img/effects-waves-preview.png',- alt: 'waves effect preview',- name: 'waves()',- description: 'Wavy band overlay effect',- },{link: '/docs/effects/scanlines',preview: '/img/effects-scanlines-preview.png',@@ -264,6 +250,20 @@ const categories: {name: 'whiteNoise()',description: 'Random grayscale noise layer',},+ {+ link: '/docs/effects/lines',+ preview: '/img/effects-lines-preview.png',+ alt: 'lines effect preview',+ name: 'lines()',+ description: 'Alternating line pattern effect',+ },+ {+ link: '/docs/effects/waves',+ preview: '/img/effects-waves-preview.png',+ alt: 'waves effect preview',+ name: 'waves()',+ description: 'Wavy band pattern effect',+ },{link: '/docs/light-leaks/light-leak-effect',preview: '/img/effects-light-leak-preview.png',diff --git a/packages/docs/docs/effects/waves.mdx b/packages/docs/docs/effects/waves.mdxindex 4cac947fbf..c16c32ef09 100644--- a/packages/docs/docs/effects/waves.mdx+++ b/packages/docs/docs/effects/waves.mdx@@ -12,7 +12,7 @@ _Part of the [`@remotion/effects`](/docs/effects/api) package._Adds repeating wavy bands to canvas-based components such as [`<Video>`](/docs/media/video), [`<HtmlInCanvas>`](/docs/remotion/html-in-canvas) and [`<Solid>`](/docs/solid).-Colors are composited over the source. Transparent colors leave the source unchanged.+Colors are composited over the source.## Preview@@ -34,7 +34,7 @@ export const MyComp: React.FC = () => {src="https://remotion.media/video.mp4"effects={[waves({- colors: ['#dff4ff', 'transparent'],+ colors: ['#dff4ff', '#7cc6ff'],direction: 'horizontal',thickness: 40,gap: 0,@@ -59,7 +59,7 @@ Pass an object with the following properties. You can also call `waves()` withouAn array of color strings for the bands. Colors are assigned cyclically. Must contain at least 2 colors.-Defaults to `['#dff4ff', 'transparent']`.+Defaults to `['#dff4ff', '#7cc6ff']`.### `direction?`diff --git a/packages/docs/static/img/effects-lines-preview.png b/packages/docs/static/img/effects-lines-preview.pngindex 505e66f246..63ead14435 100644Binary files a/packages/docs/static/img/effects-lines-preview.png and b/packages/docs/static/img/effects-lines-preview.png differdiff --git a/packages/docs/static/img/effects-waves-preview.png b/packages/docs/static/img/effects-waves-preview.pngindex 01bbb45eae..8ac32d347a 100644Binary files a/packages/docs/static/img/effects-waves-preview.png and b/packages/docs/static/img/effects-waves-preview.png differdiff --git a/packages/effects/src/lines.ts b/packages/effects/src/lines.tsindex 06f8c6338d..ce1236c575 100644--- a/packages/effects/src/lines.ts+++ b/packages/effects/src/lines.ts@@ -14,7 +14,7 @@ const {createEffect, createWebGL2ContextError} = Internals;const LINE_DIRECTIONS = ['horizontal', 'vertical'] as const;-const DEFAULT_COLORS = ['#dff4ff', 'transparent'] as const;+const DEFAULT_COLORS = ['#dff4ff', '#7cc6ff'] as const;const DEFAULT_DIRECTION = 'horizontal' as const;const DEFAULT_THICKNESS = 40 as const;const DEFAULT_GAP = 0 as const;@@ -66,7 +66,7 @@ export const linesSchema = {export type LinesDirection = (typeof LINE_DIRECTIONS)[number];export type LinesParams = {- /** Stripe colors, assigned cyclically. Defaults to light blue and transparent. */+ /** Stripe colors, assigned cyclically. Defaults to light blue shades. */readonly colors?: readonly string[];/** Line direction. Defaults to `horizontal`. */readonly direction?: LinesDirection;diff --git a/packages/effects/src/waves.ts b/packages/effects/src/waves.tsindex 145b276f2f..fbdcebfaca 100644--- a/packages/effects/src/waves.ts+++ b/packages/effects/src/waves.ts@@ -14,7 +14,7 @@ const {createEffect, createWebGL2ContextError} = Internals;const WAVE_DIRECTIONS = ['horizontal', 'vertical'] as const;-const DEFAULT_COLORS = ['#dff4ff', 'transparent'] as const;+const DEFAULT_COLORS = ['#dff4ff', '#7cc6ff'] as const;const DEFAULT_DIRECTION = 'horizontal' as const;const DEFAULT_THICKNESS = 40 as const;const DEFAULT_GAP = 0 as const;@@ -93,7 +93,7 @@ export const wavesSchema = {export type WavesDirection = (typeof WAVE_DIRECTIONS)[number];export type WavesParams = {- /** Stripe colors, assigned cyclically. Defaults to light blue and transparent. */+ /** Stripe colors, assigned cyclically. Defaults to light blue shades. */readonly colors?: readonly string[];/** Base band direction. Defaults to `horizontal`. */readonly direction?: WavesDirection;