Skip to content

remotion: Round fractional rgb() channels in interpolateColors() - #12912

Merged
samohovets merged 1 commit into
remotion-dev:mainfrom
kevin9327:fix/interpolate-colors-round-rgb
Nov 3, 2026
Merged

samohovets merged 1 commit into
remotion-dev:mainfrom
kevin9327:fix/interpolate-colors-round-rgb

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

interpolateColors() parsed rgb() / rgba() channels with Number.parseInt, so fractional channels were truncated instead of rounded. Browsers round them (rgb(127.6, 0, 0) renders as rgb(128, 0, 0)), but interpolateColors() returned rgba(127, 0, 0, 1), one level darker. For example, rgb(127.6, 0.5, 254.5) became rgba(127, 0, 254, 1) instead of rgba(128, 1, 255, 1). This shows up when an rgb() string is built from computed values.

parse255 now rounds the parsed float (ties go up, like CSS) before clamping. The existing clamping to 0-255 is unchanged.

Test: RGB > rgb rounds fractional channels in packages/core/src/test/interpolateColors.test.ts. It fails on main (Received: "rgba(127, 0, 254, 1)") and passes with the fix. All 41 tests in the file pass with bun test (1.4.2). I ran it outside the package, without the happy-dom preload, because I didn't do a full bun install. prettier --check (3.8.1) passes on both files. I did not run turbo run lint or the other packages' tests.

AI-assisted: I used an AI coding assistant to find and fix this, then reviewed the change and ran the tests myself.

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bugs Ready Ready Preview Nov 3, 2026 5:18am UTC
remotion Ready Ready Preview Nov 3, 2026 5:18am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T05:16:56.188537Z 4e852ac PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Round fractional rgb()/rgba() channels — parse255 in packages/core/src/interpolate-colors.ts:143 now uses Math.round(Number.parseFloat(str)) instead of Number.parseInt(str, 10), so rgb(127.6, 0, 0) yields rgb(128, 0, 0) like browsers. Clamping to 0-255 is unchanged, and parse255 is only reached by the legacy comma-separated rgb/rgba matchers.
  • Regression test — packages/core/src/test/interpolateColors.test.ts:144 covers rounding up (127.6, 254.5), a tie (0.5), and rounding down (127.4).

Verification notes

  • The rounding direction matches the CSS Color 4 spec: sRGB components "must be rounded towards +∞, not truncated" (Math.round is round-half-toward-+∞ for positive values).
  • Verified locally: bun test src/test from packages/core passes (740 pass, 0 fail), and oxfmt --check passes on both changed files.
  • parse255 is module-private, and a repo-wide search found no other fractional rgb()/rgba() literals, so the behavior change is isolated.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

@samohovets

Copy link
Copy Markdown
Member

Thanks!

@samohovets
samohovets merged commit 4553528 into remotion-dev:main Nov 3, 2026
20 checks passed

This branch was successfully deployed

2 active deployments
Preview – remotion — 4e852acc Deployed Nov 3, 2026 by vercel[bot]
Preview – bugs — 4e852acc Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants