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

Add multiple stops for gradient command #49

Closed
sharkdp opened this issue Aug 1, 2019 · 4 comments · Fixed by #104
Closed

Add multiple stops for gradient command #49

sharkdp opened this issue Aug 1, 2019 · 4 comments · Fixed by #104
Labels
enhancement New feature or request

Comments

@sharkdp
Copy link
Owner

sharkdp commented Aug 1, 2019

pastel gradient red orange yellow white
@sharkdp sharkdp changed the title Add multiple stops for scale command Add multiple stops for gradient command Aug 24, 2019
@sharkdp sharkdp added the enhancement New feature or request label Aug 29, 2019
@felipe-fg
Copy link
Contributor

Hello, @sharkdp.

Do you accept contributions? I can help with this issue. 😊

@sharkdp
Copy link
Owner Author

sharkdp commented Oct 6, 2019

Yes, I do.

I have implemented something like this in the past in a similar project (but in PureScript, not in Rust):
https://github.com/sharkdp/purescript-colors/blob/master/src/Color/Scale.purs

We could use this as a starting point for the design of the new functionality. In particular, the way how a "color scale" is represented as a list of (color, position) pairs where position is a number between 0 and 1.

@felipe-fg
Copy link
Contributor

So the idea is to create a color scale using pairs of colors and positions. This will allow to position a color in the middle or close to others.

Evenly distributed:

0.0            0.5            1.0
#FF0000        #00FF00        #0000FF

Unevenly distributed:

0.0      0.25                 1.0
#FF0000  #00FF00              #0000FF

After this, I can use the mixing function and compute the fraction to sample any given position in the color scale. With this new function, I can sample a gradient with multiple colors similar to the current gradient command implementation.

Is this right?

@sharkdp
Copy link
Owner Author

sharkdp commented Oct 6, 2019

Yes, exactly 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants