Clamp to prevent overflow when interpolating between two gradient stops.
Closes #397.
This commit is contained in:
parent
6a32f8c055
commit
1570c38217
|
@ -166,10 +166,8 @@ impl Gradient {
|
||||||
return lower_stop.color;
|
return lower_stop.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
lower_stop.color
|
let ratio = ((t - lower_stop.offset) / denom).min(1.0);
|
||||||
.to_f32()
|
lower_stop.color.to_f32().lerp(upper_stop.color.to_f32(), ratio).to_u8()
|
||||||
.lerp(upper_stop.color.to_f32(), (t - lower_stop.offset) / denom)
|
|
||||||
.to_u8()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in New Issue