# Cylinder Text

Editable text spinning around a tilted cylinder using WebGPU.

Element page: [https://www.remotion.dev/elements/text/cylinder-text/](https://www.remotion.dev/elements/text/cylinder-text/)

## Installation

Install this Element into a composition of your Remotion project:

```sh
npx remotion elements use https://www.remotion.dev/elements/text/cylinder-text/ --composition <composition-id> --yes
```

Replace `<composition-id>` with the ID of the composition to add the Element to. The command installs the dependencies, downloads the assets, writes the source file and adds the Element to the composition. See [`npx remotion elements use`](https://www.remotion.dev/docs/cli/elements/use.md).

## Manual installation

To install the Element manually instead, save the source below as `cylinder-text.element.tsx` in your Remotion project and import its exported component.

## Source

```tsx
import {cylinder} from '@remotion/effects/cylinder';
import React from 'react';
import {
	HtmlInCanvas,
	Interactive,
	useCurrentFrame,
	useVideoConfig,
	type InteractivitySchema,
} from 'remotion';

type CylinderTextProps = {
	readonly text?: string;
	readonly color?: string;
	readonly speed?: number;
	readonly tilt?: number;
};

const cylinderTextSchema = {
	text: {
		type: 'string',
		default: 'ALWAYS IN MOTION • ALWAYS IN MOTION • ',
		description: 'Text',
	},
	color: {type: 'color', default: '#182033', description: 'Text color'},
	speed: {
		type: 'number',
		min: -1,
		max: 1,
		step: 0.01,
		default: 1 / 6,
		description: 'Revolutions per second',
		hiddenFromList: false,
	},
	tilt: {
		type: 'rotation-degrees',
		min: 0,
		max: 85,
		default: 52,
		description: 'Tilt',
	},
} as const satisfies InteractivitySchema;

const CylinderTextInner: React.FC<CylinderTextProps> = ({
	text = 'ALWAYS IN MOTION • ALWAYS IN MOTION • ',
	color = '#182033',
	speed = 1 / 6,
	tilt = 52,
}) => {
	const frame = useCurrentFrame();
	const {fps, width, height} = useVideoConfig();

	return (
		<HtmlInCanvas
			width={width}
			height={height}
			name="Cylinder"
			effects={[
				cylinder({
					radius: Math.min(width, height) * 0.42,
					rotation: (frame / fps) * speed * 360,
					rotationX: tilt,
					rotationZ: -18,
					shading: 0.35,
				}),
			]}
		>
			<div
				style={{
					alignItems: 'center',
					color,
					display: 'flex',
					fontFamily: 'Arial, Helvetica, sans-serif',
					fontSize: width / 22,
					fontWeight: 700,
					height: '100%',
					justifyContent: 'center',
					lineHeight: 1,
					whiteSpace: 'nowrap',
					width: '100%',
				}}
			>
				{text}
			</div>
		</HtmlInCanvas>
	);
};

export const CylinderText = Interactive.create({
	Component: CylinderTextInner,
	componentName: '<CylinderText>',
	layout: 'absolute-fill',
	schema: cylinderTextSchema,
});
```

