Skip to content

Enhance Linear REC.2100 support: update HDR handling and add tests - #770

Open
Aditya30ag wants to merge 1 commit into
color-js:mainfrom
Aditya30ag:fix-rec2100-linear-hdr-gamut
Open

Aditya30ag wants to merge 1 commit into
color-js:mainfrom
Aditya30ag:fix-rec2100-linear-hdr-gamut

Conversation

@Aditya30ag

Copy link
Copy Markdown

Summary

rec2100-linear inherited the default SDR [0, 1] range from RGBColorSpace. HDR values above 1 were reported as out of gamut, and gamut mapping turned them into white.

const c = new Color("rec2100-linear", [0.5039, 2.389, 0.0447]);
c.inGamut();         // false (expected: true)
c.toGamut().coords;  // [1, 1, 1] (expected: unchanged)

Change

Following the approach suggested in the issue, rec2100-linear now defines refRange: [0, 1] instead of range:

  • The space is unbounded, so no gamut mapping happens to HDR values.
  • Percentages still resolve against 0 to 1 as before.
  • In src/toGamut.js, the ray-trace lower bound for PQ and HLG read .range[0] from the linear space. It now falls back to refRange, so they keep working.

Testing

  • Added tests to test/in_gamut.js and test/gamut.js. Without the source change they fail.
  • Full suite passes.
  • I compared gamut-mapping output before and after for rec2100-pq, rec2100-hlg, rec2020, and p3 using the css, raytrace and clip methods. Only rec2100-linear changed.

@netlify

netlify Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for colorjs ready!

Name Link
🔨 Latest commit de39386
🔍 Latest deploy log https://app.netlify.com/projects/colorjs/deploys/6aca733a9a691d0008126016
😎 Deploy Preview https://deploy-preview-770--colorjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@Aditya30ag

Copy link
Copy Markdown
Author

Fixes #630. Related: color-js/apps#11

This branch has not been deployed

No deployments
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.

1 participant