-
Notifications
You must be signed in to change notification settings - Fork 84
feat: Heatmap support #153
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
base: main
Are you sure you want to change the base?
Conversation
cfe17bc to
b3460a0
Compare
b3460a0 to
abd425d
Compare
michalsustr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, very cool and a nice demo! Left a couple comments, nothing major. Can you pls make sure it passes CI checks?
| impl std::error::Error for HeatmapErr {} | ||
|
|
||
| /// A heatmap. | ||
| pub struct Heatmap<const RESOLUTION: usize> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow, what is the motivation for having a generic here?
I find it weird, particularly when you can also pass custom_mapping and have the generic be irrelevant.
I'd just store the palette in a Vec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just revieved the old code - what would be your suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pass a palette as a Vec<Color32> and do lookups from the Vec. The RESOLUTION acts basically as histogram binning of the values -> colors mapping, linearly discretizing the ranges of values that fall into the same color. If this feels too complicated I can do it, but prefer if you do.
|
|
||
| /// Set color palette by specifying base colors from low to high | ||
| #[inline] | ||
| pub fn palette(mut self, base_colors: &[Color32]) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just simply store the colors? If user wants finer-grained details, they can use the helper function.
Add it to docs comment as a helpful reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean by that?
| } | ||
|
|
||
| /// Interpolate linear gradient with `RESOLUTION` steps from an arbitrary number of base colors. | ||
| fn linear_gradient_from_base_colors(base_colors: &[Color32]) -> [Color32; RESOLUTION] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be extracted out as a public helper function, i.e.
pub fn linear_gradient_from_base_colors(base_colors: &[Color32], resolution: i32) -> Vec<Color32>
| /// Highlight all plot elements. | ||
| #[inline] | ||
| pub fn highlight(mut self, highlight: bool) -> Self { | ||
| // FIXME: for some reason highlighting is not detected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you pls take another look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its working so i think the comment can be removed?
This was originally implemented in emilk/egui#2246 by @JohannesProgrammiert
Now we restart it!