Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: scale.colors() does not respect the change in domain #329

Open
ClaytonSmith opened this issue Feb 21, 2024 · 2 comments
Open

BUG: scale.colors() does not respect the change in domain #329

ClaytonSmith opened this issue Feb 21, 2024 · 2 comments

Comments

@ClaytonSmith
Copy link

chroma.scale('Spectral').domain([1,0]) vs chroma.scale('Spectral').domain([1,0]).colors(12) do not match.

That is to say chroma.scale('Spectral').domain([1,0]).colors(12) === chroma.scale('Spectral').colors(12)

@ClaytonSmith ClaytonSmith changed the title BUG: chroma.scale('Spectral').domain([1,0]).colors(12), Colors does not respect the change in domain BUG: chroma.scale('Spectral').domain([1,0]).colors(12), Colors() does not respect the change in domain Feb 21, 2024
@ClaytonSmith ClaytonSmith changed the title BUG: chroma.scale('Spectral').domain([1,0]).colors(12), Colors() does not respect the change in domain BUG: scale.colors() does not respect the change in domain Feb 21, 2024
@regorxxx
Copy link

Not really sure it's a bug, but more your expectation about it (not saying its not a logical expectation).

Colors returns n equidistant colors, and the output is right in both cases. If you change the domain to any other value, not an inversion, the output is "right". You are expecting that inverting the domain equals to inverting the scale, but that's not the current design. The scale is set according to the original color array passed, and .colors() just creates a new array using that reference. The domain has nothing to do with it. If you want to invert the scale, invert the colors output.

In fact, if you try any other scale modification (like .mode), .colors is not affected by it. Whatever method you apply to the scale does not change the scale, just its representation. They are different things. colors() is only related to the scale, not its representation.

@ClaytonSmith
Copy link
Author

idk, using padding and gamma do change the colors returned so I'm not sure why domain is any different.

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

No branches or pull requests

2 participants