Skip to content

Commit d36d0b4

Browse files
committed
graster-nodes: change Table<Color> params to Option<Color>
1 parent b17a66d commit d36d0b4

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

node-graph/graster-nodes/src/adjustments.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn black_and_white<T: Adjust<Color>>(
307307
GradientStops,
308308
)]
309309
mut image: T,
310-
#[default(Color::BLACK)] tint: Table<Color>,
310+
#[default(Color::BLACK)] tint: Option<Color>,
311311
#[default(40.)]
312312
#[range((-200., 300.))]
313313
reds: Percentage,
@@ -327,7 +327,6 @@ fn black_and_white<T: Adjust<Color>>(
327327
#[range((-200., 300.))]
328328
magentas: Percentage,
329329
) -> T {
330-
let tint: Option<Color> = tint.into();
331330
let tint = tint.unwrap_or(Color::BLACK);
332331

333332
image.adjust(|color| {

node-graph/graster-nodes/src/blending_nodes.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,11 @@ fn color_overlay<T: Adjust<Color>>(
166166
GradientStops,
167167
)]
168168
mut image: T,
169-
#[default(Color::BLACK)] color: Table<Color>,
169+
#[default(Color::BLACK)] color: Option<Color>,
170170
blend_mode: BlendMode,
171171
#[default(100.)] opacity: Percentage,
172172
) -> T {
173173
let opacity = (opacity as f32 / 100.).clamp(0., 1.);
174-
175-
let color: Option<Color> = color.into();
176174
let color = color.unwrap_or(Color::BLACK);
177175

178176
image.adjust(|pixel| {
@@ -206,13 +204,7 @@ mod test {
206204
// 100% of the output should come from the multiplied value
207205
let opacity = 100_f64;
208206

209-
let result = super::color_overlay(
210-
(),
211-
Table::new_from_element(Raster::new_cpu(image.clone())),
212-
Table::new_from_element(overlay_color),
213-
BlendMode::Multiply,
214-
opacity,
215-
);
207+
let result = super::color_overlay((), Table::new_from_element(Raster::new_cpu(image.clone())), Some(overlay_color), BlendMode::Multiply, opacity);
216208
let result = result.iter().next().unwrap().element;
217209

218210
// The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)

node-graph/interpreted-executor/src/node_registry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
5151
#[cfg(feature = "gpu")]
5252
into_node!(from: Table<Raster<GPU>>, to: Table<Graphic>),
5353
// into_node!(from: Table<Raster<CPU>>, to: Table<Raster<SRGBA8>>),
54+
into_node!(from: Table<Color>, to: Option<Color>),
5455
#[cfg(feature = "gpu")]
5556
into_node!(from: &WasmEditorApi, to: &WgpuExecutor),
5657
// =============

0 commit comments

Comments
 (0)