mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 21:36:09 +08:00
Change Table<Color> node inputs to Color where only one value is used so GPU nodes work (#3096)
* graster-nodes: change `Table<Color>` params to `Color` where only one value is used * Re-add support for Color and Option<Color> * Add warning when a default value isn't parsed --------- Co-authored-by: hypercube <0hypercube@gmail.com>
This commit is contained in:
@@ -307,7 +307,7 @@ fn black_and_white<T: Adjust<Color>>(
|
||||
GradientStops,
|
||||
)]
|
||||
mut image: T,
|
||||
#[default(Color::BLACK)] tint: Table<Color>,
|
||||
#[default(Color::BLACK)] tint: Color,
|
||||
#[default(40.)]
|
||||
#[range((-200., 300.))]
|
||||
reds: PercentageF32,
|
||||
@@ -327,9 +327,6 @@ fn black_and_white<T: Adjust<Color>>(
|
||||
#[range((-200., 300.))]
|
||||
magentas: PercentageF32,
|
||||
) -> T {
|
||||
let tint: Option<Color> = tint.into();
|
||||
let tint = tint.unwrap_or(Color::BLACK);
|
||||
|
||||
image.adjust(|color| {
|
||||
let color = color.to_gamma_srgb();
|
||||
|
||||
|
||||
@@ -166,15 +166,12 @@ fn color_overlay<T: Adjust<Color>>(
|
||||
GradientStops,
|
||||
)]
|
||||
mut image: T,
|
||||
#[default(Color::BLACK)] color: Table<Color>,
|
||||
#[default(Color::BLACK)] color: Color,
|
||||
blend_mode: BlendMode,
|
||||
#[default(100.)] opacity: PercentageF32,
|
||||
) -> T {
|
||||
let opacity = (opacity as f32 / 100.).clamp(0., 1.);
|
||||
|
||||
let color: Option<Color> = color.into();
|
||||
let color = color.unwrap_or(Color::BLACK);
|
||||
|
||||
image.adjust(|pixel| {
|
||||
let image = pixel.map_rgb(|channel| channel * (1. - opacity));
|
||||
|
||||
@@ -206,13 +203,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())),
|
||||
Table::new_from_element(overlay_color),
|
||||
BlendMode::Multiply,
|
||||
opacity,
|
||||
);
|
||||
let result = super::color_overlay((), Table::new_from_element(Raster::new_cpu(image.clone())), 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)
|
||||
|
||||
Reference in New Issue
Block a user