mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-25 15:55:18 +00:00
assign link_type_colors directly
This commit is contained in:
parent
d9220a0bd6
commit
53fba56ee5
@ -238,7 +238,7 @@ app.registerExtension({
|
||||
if (colorPalette.colors) {
|
||||
if (colorPalette.colors.node_slot) {
|
||||
Object.assign(app.canvas.default_connection_color_byType, colorPalette.colors.node_slot);
|
||||
customizeRenderLink(colorPalette);
|
||||
Object.assign(LGraphCanvas.link_type_colors, colorPalette.colors.node_slot);
|
||||
}
|
||||
if (colorPalette.colors.litegraph_base) {
|
||||
// Everything updates correctly in the loop, except the Node Title and Link Color for some reason
|
||||
@ -407,64 +407,3 @@ app.registerExtension({
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
function customizeRenderLink(colorPalette) {
|
||||
var LGraphCanvas = LiteGraph.LGraphCanvas;
|
||||
|
||||
if (!LGraphCanvas.prototype.getLinkColor) {
|
||||
LGraphCanvas.prototype.getLinkColor = function(link, inputNode, outputNode, colorPalette) {
|
||||
let color = null;
|
||||
if (link && link.color) {
|
||||
color = link.color;
|
||||
} else if (link) {
|
||||
const matchingEntry = inputNode.outputs.find((output) => {
|
||||
return outputNode.inputs.some((input) => input.type === output.type);
|
||||
});
|
||||
|
||||
if (matchingEntry) {
|
||||
let nodeType = matchingEntry.type;
|
||||
color = colorPalette.colors.node_slot[nodeType];
|
||||
}
|
||||
}
|
||||
return color;
|
||||
};
|
||||
}
|
||||
|
||||
if (!LGraphCanvas.prototype.originalRenderLink) {
|
||||
LGraphCanvas.prototype.originalRenderLink = LGraphCanvas.prototype.renderLink;
|
||||
}
|
||||
|
||||
LGraphCanvas.prototype.renderLink = function(
|
||||
ctx,
|
||||
a,
|
||||
b,
|
||||
link,
|
||||
skip_border,
|
||||
flow,
|
||||
color,
|
||||
start_dir,
|
||||
end_dir,
|
||||
num_sublines
|
||||
) {
|
||||
if (link) {
|
||||
const inputNode = this.graph.getNodeById(link.origin_id);
|
||||
const outputNode = this.graph.getNodeById(link.target_id);
|
||||
color = this.getLinkColor(link, inputNode, outputNode, colorPalette);
|
||||
}
|
||||
|
||||
// call the original renderLink function
|
||||
this.originalRenderLink.call(
|
||||
this,
|
||||
ctx,
|
||||
a,
|
||||
b,
|
||||
link,
|
||||
skip_border,
|
||||
flow,
|
||||
color,
|
||||
start_dir,
|
||||
end_dir,
|
||||
num_sublines
|
||||
);
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user