Clip types
Text clips
Product overview: Rendley JavaScript video editing SDK
The TextClip renders text directly on the canvas. It supports font selection, color, stroke, drop shadow, letter spacing, line height, and more.
Create a text clip
const textClip = await layer.addClip({
type: "text",
text: "Hello World",
startTime: 0,
duration: 5,
style: {
fontSize: 120,
color: "#FFFFFF",
},
});
textClip.style.setPosition(960, 540);import { Engine } from "@rendley/sdk";
await Engine.getInstance().init({
license: {
licenseName: "DOCS_PLAYGROUND",
licenseKey: "DOCS_KEY",
},
display: {
width: 1920,
height: 1080,
backgroundColor: "#000000",
view: document.getElementById("rendley-canvas") as HTMLCanvasElement,
},
});
const layer = Engine.getInstance().getTimeline().createLayer();
const textClip = await layer.addClip({
type: "text",
text: "Hello World",
startTime: 0,
duration: 5,
style: {
fontSize: 120,
color: "#FFFFFF",
},
});
textClip.style.setPosition(960, 540);
await Engine.getInstance().getTimeline().play();Change the text
textClip.setText("New Text");
const current = textClip.getText();
Background color
The text clip supports a solid background that sits behind the text:
textClip.style.setBackgroundColor("#0000FF");
Typography
The TextStyle exposes additional controls for typography:
textClip.style.setFontFamily("Inter");
textClip.style.setFontWeight("700");
textClip.style.setLetterSpacing(2);
textClip.style.setLineHeight(1.5);
textClip.style.setStrokeColor("#000000");
textClip.style.setStrokeThickness(2);
textClip.style.setPadding(10);
Custom fonts must be loaded through the FontRegistry before you can use them here.
Resizing text
Text clips have two independent ways to change size:
style.setFontSize(px): changes the glyph size. Re-rasterizes the text, so edges stay crisp.style.setScale(scaleX, scaleY): scales the rendered clip uniformly. Cheaper if you want to animate size (scale can be keyframed without re-rasterizing on every frame).
Use setFontSize for static sizing and final layout. Use setScale when you’re animating or responding to the canvas size at runtime.
const textClip = await layer.addClip({
type: "text",
text: "Resize me",
startTime: 0,
duration: 5,
style: { fontSize: 60, color: "#FFFFFF" },
});
textClip.style.setPosition(960, 540);
// Grow the font size and then scale further. Both stack.
textClip.style.setFontSize(200);
textClip.style.setScale(1.2, 1.2);import { Engine } from "@rendley/sdk";
await Engine.getInstance().init({
license: {
licenseName: "DOCS_PLAYGROUND",
licenseKey: "DOCS_KEY",
},
display: {
width: 1920,
height: 1080,
backgroundColor: "#000000",
view: document.getElementById("rendley-canvas") as HTMLCanvasElement,
},
});
const layer = Engine.getInstance().getTimeline().createLayer();
const textClip = await layer.addClip({
type: "text",
text: "Resize me",
startTime: 0,
duration: 5,
style: { fontSize: 60, color: "#FFFFFF" },
});
textClip.style.setPosition(960, 540);
// Grow the font size and then scale further. Both stack.
textClip.style.setFontSize(200);
textClip.style.setScale(1.2, 1.2);
await Engine.getInstance().getTimeline().play();To animate the size over time, keyframe scaleX and scaleY through the Property Animator, don’t animate fontSize per frame; it’s not an animatable property and would re-rasterize constantly.
Drop shadow
const textClip = await layer.addClip({
type: "text",
text: "Drop Shadow",
startTime: 0,
duration: 5,
style: { fontSize: 160, color: "#FFFFFF" },
});
textClip.style.setPosition(960, 540);
textClip.style.setDropShadowColor("#000000");
textClip.style.setDropShadowAlpha(0.6);
textClip.style.setDropShadowBlur(8);
textClip.style.setDropShadowDistance(10);
textClip.style.setDropShadowAngle(Math.PI / 4);import { Engine } from "@rendley/sdk";
await Engine.getInstance().init({
license: {
licenseName: "DOCS_PLAYGROUND",
licenseKey: "DOCS_KEY",
},
display: {
width: 1920,
height: 1080,
backgroundColor: "#000000",
view: document.getElementById("rendley-canvas") as HTMLCanvasElement,
},
});
const layer = Engine.getInstance().getTimeline().createLayer();
const textClip = await layer.addClip({
type: "text",
text: "Drop Shadow",
startTime: 0,
duration: 5,
style: { fontSize: 160, color: "#FFFFFF" },
});
textClip.style.setPosition(960, 540);
textClip.style.setDropShadowColor("#000000");
textClip.style.setDropShadowAlpha(0.6);
textClip.style.setDropShadowBlur(8);
textClip.style.setDropShadowDistance(10);
textClip.style.setDropShadowAngle(Math.PI / 4);
await Engine.getInstance().getTimeline().play();What to read next
- Styling positions, scales, rotates and colors a clip.
- Fonts loads Google Fonts or your own files for text clips.
- HTML text clips render rich inline markup when plain text is not enough.
- API reference:
TextClip,TextStyle.