Improve previewing node data (#1446)

* Improve preview

* Improve contrast

* Restructure in order to duplicate code

* Code review nits

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2023-11-04 09:52:26 +00:00
committed by GitHub
parent c823016316
commit e0ac073805
18 changed files with 326 additions and 202 deletions

View File

@@ -127,12 +127,12 @@ impl Gradient {
// Compute the color of the inserted stop
let get_color = |index: usize, time: f64| match (self.positions[index].1, self.positions.get(index + 1).and_then(|x| x.1)) {
// Lerp between the nearest colours if applicable
// Lerp between the nearest colors if applicable
(Some(a), Some(b)) => a.lerp(
b,
((time - self.positions[index].0) / self.positions.get(index + 1).map(|end| end.0 - self.positions[index].0).unwrap_or_default()) as f32,
),
// Use the start or the end colour if applicable
// Use the start or the end color if applicable
(Some(v), _) | (_, Some(v)) => v,
_ => Color::WHITE,
};