-
Notifications
You must be signed in to change notification settings - Fork 89
Add initial Colormap implementation with keypoints #225
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
…oints
- Introduce `Colormap` struct to map parameters to colors.
- Support uniform and non-uniform keypoints map inputs.
- Support for sRBG color interpolation for now.
- Add unit tests:
- Uniform and non-uniform keypoints.
- Edge cases (empty colormap, single color).
- Out-of-bounds parameter handling.
This PR is part of issue emilk#188
|
View snapshot changes at kitdiff |
| /// make this assumption and will only sample the colormap in this range. | ||
| /// However, this is not enforced, so feel free to go against this for your own special use-cases. | ||
| pub struct Colormap { | ||
| data: ColormapData, |
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'm anticipating additional fields here like the interpolation function to use.
|
|
||
| /// Get color at a given position. | ||
| pub fn get(&self, t: f32) -> Color32 { | ||
| self.data.get(t, ColorInterpolation::SRGB) |
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 haven't exposed this yet because I'm wondering if it will be more efficient to store the colormap colors in the desired interpolation space. And then convert them after interpolation. In this case, the interpolation function is the same for everything, it's just a lerp. And then the functions would be the conversions to/from sRGB.
| // Internal representation of colormap data. | ||
| // May support things like functions in the future. | ||
| enum ColormapData { | ||
| Uniform(UniformKeypoints), |
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 kept these separate instead of mapping everything to non-uniform keypoints because the sampling of uniform keypoints can be made much faster.
Colormapstruct to map parameters to colors.