Skip to content

Commit f781b8c

Browse files
committed
add new colormap trait
- get_color(h) takes a floating point value between 0.0 and 1.0 and returns a color corresponding to this value - get_color_normalized(h, min, max) does the same but sets the bounds to min and max instead of 0.0 and 1.0 - the floating point type is f32 by default but can be chosen arbitratily as long as it complies with the trait defined in the num_traits package
1 parent acf5158 commit f781b8c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pub trait ColorScale<ColorType: crate::prelude::Color, FloatType=f32>
2+
where
3+
FloatType: Float,
4+
{
5+
fn get_color(&self, h: FloatType) -> ColorType {
6+
self.get_color_normalized(h, FloatType::zero(), FloatType::one())
7+
}
8+
9+
fn get_color_normalized(&self, h: FloatType, min: FloatType, max: FloatType) -> ColorType;
10+
}

0 commit comments

Comments
 (0)