Add initial Colormap implementation with keypoints#225
Add initial Colormap implementation with keypoints#225kitizz wants to merge 4 commits intoemilk:mainfrom
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.
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.
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.
I kept these separate instead of mapping everything to non-uniform keypoints because the sampling of uniform keypoints can be made much faster.
|
Hi @michalsustr, |
Colormapstruct to map parameters to colors.