vulkan: add support for blend buffers
This commit is contained in:
parent
1220539a41
commit
cb9da22ec2
20 changed files with 638 additions and 78 deletions
15
src/theme.rs
15
src/theme.rs
|
|
@ -120,20 +120,21 @@ impl Color {
|
|||
[self.r * a, self.g * a, self.b * a, self.a * a]
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub fn to_array_linear(self) -> [f32; 4] {
|
||||
pub fn to_array_linear(self, alpha: Option<f32>) -> [f32; 4] {
|
||||
fn to_linear(srgb: f32) -> f32 {
|
||||
if srgb <= 0.04045 {
|
||||
srgb / 12.92
|
||||
} else {
|
||||
(srgb + 0.055 / 1.055).powf(2.4)
|
||||
((srgb + 0.055) / 1.055).powf(2.4)
|
||||
}
|
||||
}
|
||||
let a1 = if self.a == 0.0 { 1.0 } else { self.a };
|
||||
let a2 = self.a * alpha.unwrap_or(1.0);
|
||||
[
|
||||
to_linear(self.r),
|
||||
to_linear(self.g),
|
||||
to_linear(self.b),
|
||||
self.a,
|
||||
to_linear(self.r / a1) * a2,
|
||||
to_linear(self.g / a1) * a2,
|
||||
to_linear(self.b / a1) * a2,
|
||||
a2,
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue