🎥 Make videos programmatically with React
Elements: Add Tear effect (#11289)
Igor Samokhovetsa0db3770f68e
diff --git a/packages/docs/elements/commerce/tear/index.mdx b/packages/docs/elements/commerce/tear/index.mdxnew file mode 100644index 0000000000..27acfce6f3--- /dev/null+++ b/packages/docs/elements/commerce/tear/index.mdx@@ -0,0 +1,12 @@+---+title: Tear apart+description: A tear effect that can be applied to any content.+image: https://remotion.media/elements/commerce-tear-preview.png+---++import {ElementPage} from '@site/src/components/Elements/ElementPage';+import {getElementDefinition} from '@site/src/components/Elements/element-utils';++# Tear apart++<ElementPage definition={getElementDefinition('commerce/tear')} sourceFile="./tear.tsx" />diff --git a/packages/docs/elements/commerce/tear/tear.tsx b/packages/docs/elements/commerce/tear/tear.tsxnew file mode 100644index 0000000000..f633c55f5f--- /dev/null+++ b/packages/docs/elements/commerce/tear/tear.tsx@@ -0,0 +1,66 @@+import {scale} from '@remotion/effects/scale';+import {tear} from '@remotion/effects/tear';+import React from 'react';+import {+ CanvasImage,+ Easing,+ HtmlInCanvas,+ interpolate,+ useCurrentFrame,+} from 'remotion';++export const Tear: React.FC = () => {+ const frame = useCurrentFrame();++ return (+ <HtmlInCanvas+ effects={[+ scale({+ scale: 0.75,+ }),+ tear({+ jaggedness: 24,+ progress: interpolate(frame, [15, 25], [0, 1], {+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ easing: [+ Easing.spring({+ damping: 200,+ mass: 1,+ stiffness: 100,+ allowTail: true,+ durationRestThreshold: 0.02,+ overshootClamping: false,+ }),+ ],+ }),+ rotation: interpolate(frame, [15, 25], [0, 5], {+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ easing: [+ Easing.spring({+ damping: 200,+ mass: 1,+ stiffness: 100,+ allowTail: true,+ durationRestThreshold: 0.02,+ overshootClamping: false,+ }),+ ],+ }),+ }),+ ]}+ height={720}+ name="Tear"+ width={1280}+ >+ <CanvasImage+ fit="cover"+ height={720}+ name="A graphic"+ src="https://remotion.media/elements/commerce-tear-a-graphic.png"+ width={1280}+ />+ </HtmlInCanvas>+ );+};diff --git a/packages/docs/src/components/Elements/element-definitions.ts b/packages/docs/src/components/Elements/element-definitions.tsindex 70586a06d4..bebbf84835 100644--- a/packages/docs/src/components/Elements/element-definitions.ts+++ b/packages/docs/src/components/Elements/element-definitions.ts@@ -28,6 +28,7 @@ import {import {ProductDiscountCallout} from '../../../elements/commerce/product-discount-callout/product-discount-callout';import {ProductOffer} from '../../../elements/commerce/product-offer/product-offer';import {Shine} from '../../../elements/commerce/shine/shine';+import {Tear} from '../../../elements/commerce/tear/tear';import {HorizontalBarChart} from '../../../elements/data/horizontal-bar-chart/horizontal-bar-chart';import {LineChart} from '../../../elements/data/line-chart/line-chart';import {NumberCounter} from '../../../elements/data/number-counter/number-counter';@@ -529,6 +530,28 @@ const elementImplementations = [installationMode: 'wrapped',width: 1920,},+ {+ slug: 'commerce/tear',+ component: Tear,+ contributors: [],+ description: 'A tear effect that can be applied to any content.',+ dependencies: [{name: '@remotion/effects', version: null}],+ durationInFrames: 45,+ elementHeight: 720,+ elementWidth: 1280,+ fps: 30,+ height: 1080,+ posterFrame: 25,+ preview: {+ previewLayout: 'composition',+ posterUrl: 'https://remotion.media/elements/commerce-tear-preview.png',+ videoUrl: 'https://remotion.media/elements/commerce-tear-preview.mp4',+ },+ safeArea: 0,+ initialProps: null,+ installationMode: 'wrapped',+ width: 1920,+ },{slug: 'data/horizontal-bar-chart',component: HorizontalBarChart,@@ -1073,7 +1096,10 @@ const elementImplementations = [readonly slug: ElementSlug;})[];-const htmlInCanvasElementSlugs = new Set<ElementSlug>(['commerce/shine']);+const htmlInCanvasElementSlugs = new Set<ElementSlug>([+ 'commerce/shine',+ 'commerce/tear',+]);export const elementDefinitions = elementImplementations.map((definition) => ({...elementRegistry[definition.slug],diff --git a/packages/docs/src/components/Elements/element-registry.ts b/packages/docs/src/components/Elements/element-registry.tsindex 666d834ddd..8e1c84e4e0 100644--- a/packages/docs/src/components/Elements/element-registry.ts+++ b/packages/docs/src/components/Elements/element-registry.ts@@ -82,6 +82,10 @@ export const elementRegistry = {category: 'commerce',displayName: 'Shine',},+ 'commerce/tear': {+ category: 'commerce',+ displayName: 'Tear apart',+ },'data/horizontal-bar-chart': {category: 'data',displayName: 'Horizontal Bar Chart',