Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
sequence holding only that part, framed on the subject, with a hook title,
word-timed captions and, with `export`, a file in `exports/`. The source
timeline is left as it was.
- **One background box for a title.** A text clip's new **Bg shape** (`bgShape`)
set to **box** draws its background as a single rounded box: the text box
(`boxW` × `boxH`) when it has one, so a brand box or lower-third can be taller
than its text, else the whole block of lines. **lines** (the default) keeps a
pill per line.

### Fixed
- **Text backgrounds no longer overlap on wrapped lines.** At usual line
heights each line's pill ran into the next, and with a see-through
background the overlap showed as a darker band across the text. Stacked
pills now meet halfway between the lines and are filled as one shape.
- **An export no longer sits at 0% for good.** Fast export hands its frames
only to encoder workers that have started. A worker that never ran (one held
at its first line by a debugger attached to the tab, as test tools do) kept
Expand Down
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ These are quick looks. For real grading use `props.grade` (see "Color" below).
| `bold` / `weight` | true / 0 | `weight` (300–900) overrides `bold` when non-zero |
| `italic` `uppercase` | false | |
| `align` | "center" | left · center · right · **justify** (inserts spaces between words to fill the text box width, or ~85% of the canvas when no box) |
| `boxW` `boxH` | 0 | px text box; **0 = hug content**. When both > 0, corner handles resize the box (not `scale`). Default: fixed `fontSize`, word-wrap inside the box. |
| `boxW` `boxH` | 0 | px text box; **0 = hug content**. When both > 0, corner handles resize the box (not `scale`). Default: fixed `fontSize`, word-wrap inside the box. The background fills the box only with `bgShape:"box"`. |
| `boxFit` | false | when a box is set: `false` = wrap at fixed font size; `true` = scale font down (up to `fontSize`) so the whole text fits |
| `vAlign` | "middle" | top · middle · bottom — vertical alignment of the text block inside the box |
| `direction` | "auto" | auto · ltr · rtl — `auto` detects per line (Hebrew/Arabic → RTL); all `textAnim` modes honor reading direction (wipe, typewriter reveal, word/letter layout) |
Expand All @@ -462,7 +462,8 @@ These are quick looks. For real grading use `props.grade` (see "Color" below).
| `glow` | 0 | neon glow strength (0–100); replaces the drop shadow |
| `glowColor` | "" | glow color ("" = use the text color) |
| `strokeWidth` `strokeColor` | 0, "#000" | text outline |
| `bgColor` `bgOpacity` | "#000", 0 | rounded pill behind each line |
| `bgColor` `bgOpacity` | "#000", 0 | text background, drawn when `bgOpacity` > 0 (shape set by `bgShape`) |
| `bgShape` | "lines" | **lines** = a rounded pill hugging each line; wrapped lines that would overlap meet halfway instead, as one shape · **box** = one rounded box: the `boxW`×`boxH` text box when the clip has one (a brand box or lower-third taller than its text), else the whole text block plus padding. `boxH` only changes the background in `box` |
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
| `textAnim` | "none" | typewriter · word-pop · word-slide · karaoke · **highlight** (every word shown; the one being said in `highlightColor`) · **letter-pop** (per-character entrance; Arabic/Indic auto-fallback to per-word clusters so joined letters shape correctly) · **wave** (looping per-character ride; same shaping fallback) · **bounce** (looping per-word hop) · **shake** (looping jitter) · **clip-reveal** (wipe-mask sweep, per line) · **zoom-in** (scale + opacity settle) · **font-cut** (rhythmically swaps typeface, then settles — see `fontCutSet`) · **rise-mask** (line rises from behind its baseline, lower-third reveal) |
| `wordRate` | 0.15 | seconds per word (typewriter: /4, letter-pop: /3 per character); also staggers `clip-reveal`/`zoom-in`/`rise-mask` per line |
| `wordTimes` | — | `[[start, end], …]`, one pair per word (seconds from the clip's start): word-pop, word-slide, karaoke and highlight follow these instead of `wordRate` — a caption timed to speech. If the text is edited to another number of words they are spread over the clip. See "Captions" |
Expand Down
40 changes: 31 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const DEFAULT_PROPS = {
glow: 0, glowColor: "", // neon glow (glowColor defaults to fill)
textAnim: "none", wordRate: 0.15, direction: "auto", highlightColor: "#ffd166",
strokeWidth: 0, strokeColor: "#000000", bgColor: "#000000", bgOpacity: 0,
bgShape: "lines", // lines = a pill per line · box = one box (the text box, else the block)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
boxW: 0, boxH: 0, // text box (px); 0 = hug content. Resize handles edit these.
boxFit: false, // false = wrap at fixed fontSize; true = scale font to fit box
vAlign: "middle", // top | middle | bottom — vertical align of the text block in the box
Expand Down Expand Up @@ -7208,6 +7209,7 @@ function renderInspector(lite) {
${row("Stroke col.", `<input type="color" data-k="strokeColor" value="${p.strokeColor}">`, "", "strokeColor")}
${row("Bg color", `<input type="color" data-k="bgColor" value="${p.bgColor}">`, "", "bgColor")}
${slider("bgOpacity", 0, 1, 0.05, p.bgOpacity)}
${sel("Bg shape", "bgShape", ["lines", "box"], p.bgShape === "box" ? "box" : "lines")}
${slider("textShadow", 0, 40, 1, p.textShadow)}
${slider("glow", 0, 100, 1, p.glow)}
${row("Glow color", `<input type="color" data-k="glowColor" value="${p.glowColor || p.color}">
Expand Down Expand Up @@ -15978,18 +15980,38 @@ function drawText(c, p, local) {
}
const shadowBlur = (p.textShadow === 0 ? 0 : (+p.textShadow || 12)) * size / 100;

// background pill per line (static — anchors the animated words)
// text background (static — anchors the animated words)
if (p.bgOpacity > 0) {
ctx2d.fillStyle = hexToRgba(p.bgColor || "#000", clamp(p.bgOpacity, 0, 1));
const padX = size * 0.4, padY = size * 0.18, r = size * 0.28;
rawLines.forEach((ln, i) => {
if (!ln.trim()) return;
const w = lineWidths[i];
const y = y0 + i * lh;
ctx2d.beginPath();
ctx2d.roundRect(lineCx(i) - w / 2 - padX, y - lh / 2 - padY + lh * 0.08, w + padX * 2, lh + padY * 2 - lh * 0.16, r);
ctx2d.fill();
});
const half = (lh + padY * 2 - lh * 0.16) / 2; // a lone pill's half height
ctx2d.beginPath();
if (p.bgShape === "box") {
// one box: the text box when there is one, else the whole block plus padding
if (useBox) ctx2d.roundRect(-boxW / 2, -boxH / 2, boxW, boxH, Math.min(r, boxW / 2, boxH / 2));
else ctx2d.roundRect(-blockW / 2 - padX, y0 - half, blockW + padX * 2, (nLines - 1) * lh + half * 2, r);
} else {
// a pill per line; where neighbours would overlap they meet halfway instead,
// and the whole shape is filled once, so no strip is painted twice
const pills = rawLines.map((ln, i) => {
if (!ln.trim()) return null;
const w = lineWidths[i];
return { l: lineCx(i) - w / 2 - padX, r: lineCx(i) + w / 2 + padX, y: y0 + i * lh };
});
const meet = half * 2 >= lh;
pills.forEach((q, i) => {
if (!q) return;
const up = meet ? pills[i - 1] : null, down = meet ? pills[i + 1] : null;
const top = up ? q.y - lh / 2 : q.y - half;
const bot = down ? q.y + lh / 2 : q.y + half;
// a corner a neighbour covers is square, so stacked pills read as one shape
const tl = up && up.l <= q.l + 1 ? 0 : r, tr = up && up.r >= q.r - 1 ? 0 : r;
const bl = down && down.l <= q.l + 1 ? 0 : r, br = down && down.r >= q.r - 1 ? 0 : r;
const rr = (v) => Math.min(v, (bot - top) / 2, (q.r - q.l) / 2);
ctx2d.roundRect(q.l, top, q.r - q.l, bot - top, [rr(tl), rr(tr), rr(br), rr(bl)]);
});
}
ctx2d.fill();
}

const fillFor = (y) => {
Expand Down
40 changes: 31 additions & 9 deletions docs/demo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const DEFAULT_PROPS = {
glow: 0, glowColor: "", // neon glow (glowColor defaults to fill)
textAnim: "none", wordRate: 0.15, direction: "auto", highlightColor: "#ffd166",
strokeWidth: 0, strokeColor: "#000000", bgColor: "#000000", bgOpacity: 0,
bgShape: "lines", // lines = a pill per line · box = one box (the text box, else the block)
boxW: 0, boxH: 0, // text box (px); 0 = hug content. Resize handles edit these.
boxFit: false, // false = wrap at fixed fontSize; true = scale font to fit box
vAlign: "middle", // top | middle | bottom — vertical align of the text block in the box
Expand Down Expand Up @@ -7208,6 +7209,7 @@ function renderInspector(lite) {
${row("Stroke col.", `<input type="color" data-k="strokeColor" value="${p.strokeColor}">`, "", "strokeColor")}
${row("Bg color", `<input type="color" data-k="bgColor" value="${p.bgColor}">`, "", "bgColor")}
${slider("bgOpacity", 0, 1, 0.05, p.bgOpacity)}
${sel("Bg shape", "bgShape", ["lines", "box"], p.bgShape === "box" ? "box" : "lines")}
${slider("textShadow", 0, 40, 1, p.textShadow)}
${slider("glow", 0, 100, 1, p.glow)}
${row("Glow color", `<input type="color" data-k="glowColor" value="${p.glowColor || p.color}">
Expand Down Expand Up @@ -15978,18 +15980,38 @@ function drawText(c, p, local) {
}
const shadowBlur = (p.textShadow === 0 ? 0 : (+p.textShadow || 12)) * size / 100;

// background pill per line (static — anchors the animated words)
// text background (static — anchors the animated words)
if (p.bgOpacity > 0) {
ctx2d.fillStyle = hexToRgba(p.bgColor || "#000", clamp(p.bgOpacity, 0, 1));
const padX = size * 0.4, padY = size * 0.18, r = size * 0.28;
rawLines.forEach((ln, i) => {
if (!ln.trim()) return;
const w = lineWidths[i];
const y = y0 + i * lh;
ctx2d.beginPath();
ctx2d.roundRect(lineCx(i) - w / 2 - padX, y - lh / 2 - padY + lh * 0.08, w + padX * 2, lh + padY * 2 - lh * 0.16, r);
ctx2d.fill();
});
const half = (lh + padY * 2 - lh * 0.16) / 2; // a lone pill's half height
ctx2d.beginPath();
if (p.bgShape === "box") {
// one box: the text box when there is one, else the whole block plus padding
if (useBox) ctx2d.roundRect(-boxW / 2, -boxH / 2, boxW, boxH, Math.min(r, boxW / 2, boxH / 2));
else ctx2d.roundRect(-blockW / 2 - padX, y0 - half, blockW + padX * 2, (nLines - 1) * lh + half * 2, r);
} else {
// a pill per line; where neighbours would overlap they meet halfway instead,
// and the whole shape is filled once, so no strip is painted twice
const pills = rawLines.map((ln, i) => {
if (!ln.trim()) return null;
const w = lineWidths[i];
return { l: lineCx(i) - w / 2 - padX, r: lineCx(i) + w / 2 + padX, y: y0 + i * lh };
});
const meet = half * 2 >= lh;
pills.forEach((q, i) => {
if (!q) return;
const up = meet ? pills[i - 1] : null, down = meet ? pills[i + 1] : null;
const top = up ? q.y - lh / 2 : q.y - half;
const bot = down ? q.y + lh / 2 : q.y + half;
// a corner a neighbour covers is square, so stacked pills read as one shape
const tl = up && up.l <= q.l + 1 ? 0 : r, tr = up && up.r >= q.r - 1 ? 0 : r;
const bl = down && down.l <= q.l + 1 ? 0 : r, br = down && down.r >= q.r - 1 ? 0 : r;
const rr = (v) => Math.min(v, (bot - top) / 2, (q.r - q.l) / 2);
ctx2d.roundRect(q.l, top, q.r - q.l, bot - top, [rr(tl), rr(tr), rr(br), rr(bl)]);
});
}
ctx2d.fill();
}

const fillFor = (y) => {
Expand Down
Loading
Loading