mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Add Color32::lerp_to_gamma (#4627)
Add `lerp_to_gamma` utility function to `Color32` --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
@@ -342,7 +342,7 @@ impl Gradient {
|
||||
(0..=n)
|
||||
.map(|i| {
|
||||
let t = i as f32 / n as f32;
|
||||
lerp_color_gamma(left, right, t)
|
||||
left.lerp_to_gamma(right, t)
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
@@ -634,12 +634,3 @@ fn mul_color_gamma(left: Color32, right: Color32) -> Color32 {
|
||||
(left.a() as f32 * right.a() as f32 / 255.0).round() as u8,
|
||||
)
|
||||
}
|
||||
|
||||
fn lerp_color_gamma(left: Color32, right: Color32, t: f32) -> Color32 {
|
||||
Color32::from_rgba_premultiplied(
|
||||
lerp((left[0] as f32)..=(right[0] as f32), t).round() as u8,
|
||||
lerp((left[1] as f32)..=(right[1] as f32), t).round() as u8,
|
||||
lerp((left[2] as f32)..=(right[2] as f32), t).round() as u8,
|
||||
lerp((left[3] as f32)..=(right[3] as f32), t).round() as u8,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user