psiphi75/sonogram

Create specific points for the gradient

Opened this issue · 0 comments

@psiphi75 I was wondering if the gradient could be done the other way around, mapping dB threshold values to colours?

So something like..

let mut gradient = ColourGradient::new();
gradient.add_colour(RGBAColour::new(-100.0, 0, 0, 0, 255));     // Black - I was originally thinking -f32::INFINITY but it might be better to define a lower bound
gradient.add_colour(RGBAColour::new(-60.0, 55, 0, 110, 255));  // Purple
gradient.add_colour(RGBAColour::new(-40.0, 0, 0, 180, 255));   // Blue
gradient.add_colour(RGBAColour::new(-20.0, 0, 255, 255, 255)); // Cyan
gradient.add_colour(RGBAColour::new(-10.0, 255, 255, 0, 255)); // Green
gradient.add_colour(RGBAColour::new(-0.0, 255, 0, 0, 255));   // Red

This way you could define a minimum and maximum amplitude range, and generating the gradient would be much easier outside the package as the same colour stops can be calculated based on that range. What do you think?

Originally posted by @juho in #6 (comment)