Skip to content

Commit

Permalink
added back separate threshold input
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBxl committed Nov 21, 2024
1 parent 88a7c18 commit fdae857
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/graph-engine/src/nodes/color/matchAlpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class NodeDefinition extends Node {
foreground: ColorType;
background: ColorType;
reference: ColorType;
threshold: number;
precision: number;
}>;
declare outputs: ToOutput<{
Expand Down Expand Up @@ -49,6 +50,12 @@ export default class NodeDefinition extends Node {
default: Gray
}
});
this.addInput('threshold', {
type: {
...NumberSchema,
default: 0.01
}
});
this.addInput('precision', {
type: {
...NumberSchema,
Expand All @@ -68,7 +75,7 @@ export default class NodeDefinition extends Node {
}

execute(): void | Promise<void> {
const { foreground, background, reference, precision } =
const { foreground, background, reference, threshold, precision } =
this.getAllInputs();

const bg = toColor(background);
Expand Down Expand Up @@ -136,7 +143,7 @@ export default class NodeDefinition extends Node {
// to compare normalized colors
const comp = blendColors(fg, bg, alpha);

if (comp.deltaE2000(ref) / 100 > precision) {
if (comp.deltaE2000(ref) / 100 > threshold) {
alpha = Number.NaN;
inRange = false;
}
Expand Down

0 comments on commit fdae857

Please sign in to comment.