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

Extend Palette mechanism and offer more choices of palettes #199

Open
remifontan opened this issue Oct 28, 2020 · 0 comments
Open

Extend Palette mechanism and offer more choices of palettes #199

remifontan opened this issue Oct 28, 2020 · 0 comments

Comments

@remifontan
Copy link

@remifontan remifontan commented Oct 28, 2020

Extend Palette trait

I've been recently using plotters to do some scatters plots of point sequences. Its great, I love the gif backend. amazing crate.

As I wanted to colors my plots, I've been exploring the Palette trait.

I quickly wished for the following features:

  • more choices of palette
    Following link has great examples of high quality palettes that could be used: https://bids.github.io/colormap/
  • a way to index a palette color by float, in [0; 1] range
  • a way to interpolate palette.

I'm not sure what would be the best way to implemented those features.. The Palette trait could be extended with functions like those

pub trait Palette {
    ...
    fn linear_sample(x: f64) -> RBColor;
    fn point_sample(x: f64) -> RBColor;
}

or perhaps a new struct could be implemented, InterpolatedPaletteColor, and its trait Color implementation would do the interpolation.

pub struct InterpolatedPaletteColor<P: Palette>(f64, PhantomData<P>);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.