WIP graster-nodes: change Color params to Option<Color>

This commit is contained in:
firestar99
2025-08-26 11:24:10 +02:00
parent c716e83a7c
commit 648178f852
5 changed files with 37 additions and 3 deletions

View File

@@ -341,7 +341,7 @@ fn black_and_white<T: Adjust<Color>>(
)]
#[gpu_image]
mut image: T,
#[default(Color::BLACK)] tint: Color,
#[default(Color::BLACK)] tint: Option<Color>,
#[default(40.)]
#[range((-200., 300.))]
reds: PercentageF32,
@@ -361,6 +361,8 @@ fn black_and_white<T: Adjust<Color>>(
#[range((-200., 300.))]
magentas: PercentageF32,
) -> T {
let tint = tint.unwrap_or(Color::BLACK);
image.adjust(|color| {
let color = color.to_gamma_srgb();

View File

@@ -169,11 +169,12 @@ fn color_overlay<T: Adjust<Color>>(
)]
#[gpu_image]
mut image: T,
#[default(Color::BLACK)] color: Color,
#[default(Color::BLACK)] color: Option<Color>,
blend_mode: BlendMode,
#[default(100.)] opacity: PercentageF32,
) -> T {
let opacity = (opacity as f32 / 100.).clamp(0., 1.);
let color = color.unwrap_or(Color::BLACK);
image.adjust(|pixel| {
let image = pixel.map_rgb(|channel| channel * (1. - opacity));
@@ -206,7 +207,7 @@ mod test {
// 100% of the output should come from the multiplied value
let opacity = 100.;
let result = super::color_overlay((), Table::new_from_element(Raster::new_cpu(image.clone())), overlay_color, BlendMode::Multiply, opacity);
let result = super::color_overlay((), Table::new_from_element(Raster::new_cpu(image.clone())), Some(overlay_color), BlendMode::Multiply, opacity);
let result = result.iter().next().unwrap().element;
// The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)