Skip to content

Unhandled error with a decimal gamma value and input out of domain #331

@tibotiber

Description

@tibotiber

Hello,

Before starting, let me say I love this library and have been relying on it for years. I'm even singing its praise in our own developer documentation: https://docs.smplrspace.com/api-reference/color/overview#a-little-context ;). So THANK YOU!

I've just come across what I think is a bug. If I use a scale with a decimal gamma value and pass it an out of domain input. It's crashing.

Code:

console.log(chroma.scale('YlGn').domain([5, 15]).gamma(1.2)(4).hex())

Error:

Uncaught Error: unknown format: 
    at new Color2 (chroma-js.js?v=8a5f8334:121:17)
    at chroma (chroma-js.js?v=8a5f8334:138:16)
    at f (chroma-js.js?v=8a5f8334:1998:19)

Happy to provide any additional details, testing, or help on a PR if given pointers of where to handle this.

Take care!

PS: this can be easily handled in userland by clamping the value before passing it in, so not a really bad one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions