mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
link colors change after palette swap
didn't work previously as same function was defined repeatedly
This commit is contained in:
parent
327e49da42
commit
d9220a0bd6
@ -238,6 +238,7 @@ app.registerExtension({
|
|||||||
if (colorPalette.colors) {
|
if (colorPalette.colors) {
|
||||||
if (colorPalette.colors.node_slot) {
|
if (colorPalette.colors.node_slot) {
|
||||||
Object.assign(app.canvas.default_connection_color_byType, colorPalette.colors.node_slot);
|
Object.assign(app.canvas.default_connection_color_byType, colorPalette.colors.node_slot);
|
||||||
|
customizeRenderLink(colorPalette);
|
||||||
}
|
}
|
||||||
if (colorPalette.colors.litegraph_base) {
|
if (colorPalette.colors.litegraph_base) {
|
||||||
// Everything updates correctly in the loop, except the Node Title and Link Color for some reason
|
// Everything updates correctly in the loop, except the Node Title and Link Color for some reason
|
||||||
@ -250,7 +251,6 @@ app.registerExtension({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
customizeRenderLink(colorPalette);
|
|
||||||
app.canvas.draw(true, true);
|
app.canvas.draw(true, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -411,24 +411,28 @@ app.registerExtension({
|
|||||||
function customizeRenderLink(colorPalette) {
|
function customizeRenderLink(colorPalette) {
|
||||||
var LGraphCanvas = LiteGraph.LGraphCanvas;
|
var LGraphCanvas = LiteGraph.LGraphCanvas;
|
||||||
|
|
||||||
function getLinkColor(link, inputNode, outputNode, colorPalette) {
|
if (!LGraphCanvas.prototype.getLinkColor) {
|
||||||
let color = null;
|
LGraphCanvas.prototype.getLinkColor = function(link, inputNode, outputNode, colorPalette) {
|
||||||
if (link && link.color) {
|
let color = null;
|
||||||
color = link.color;
|
if (link && link.color) {
|
||||||
} else if (link) {
|
color = link.color;
|
||||||
const matchingEntry = inputNode.outputs.find((output) => {
|
} else if (link) {
|
||||||
return outputNode.inputs.some((input) => input.type === output.type);
|
const matchingEntry = inputNode.outputs.find((output) => {
|
||||||
});
|
return outputNode.inputs.some((input) => input.type === output.type);
|
||||||
|
});
|
||||||
|
|
||||||
if (matchingEntry) {
|
if (matchingEntry) {
|
||||||
let nodeType = matchingEntry.type;
|
let nodeType = matchingEntry.type;
|
||||||
color = colorPalette.colors.node_slot[nodeType];
|
color = colorPalette.colors.node_slot[nodeType];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return color;
|
||||||
return color;
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var originalRenderLink = LGraphCanvas.prototype.renderLink;
|
if (!LGraphCanvas.prototype.originalRenderLink) {
|
||||||
|
LGraphCanvas.prototype.originalRenderLink = LGraphCanvas.prototype.renderLink;
|
||||||
|
}
|
||||||
|
|
||||||
LGraphCanvas.prototype.renderLink = function(
|
LGraphCanvas.prototype.renderLink = function(
|
||||||
ctx,
|
ctx,
|
||||||
@ -445,10 +449,11 @@ function customizeRenderLink(colorPalette) {
|
|||||||
if (link) {
|
if (link) {
|
||||||
const inputNode = this.graph.getNodeById(link.origin_id);
|
const inputNode = this.graph.getNodeById(link.origin_id);
|
||||||
const outputNode = this.graph.getNodeById(link.target_id);
|
const outputNode = this.graph.getNodeById(link.target_id);
|
||||||
color = getLinkColor(link, inputNode, outputNode, colorPalette);
|
color = this.getLinkColor(link, inputNode, outputNode, colorPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
originalRenderLink.call(
|
// call the original renderLink function
|
||||||
|
this.originalRenderLink.call(
|
||||||
this,
|
this,
|
||||||
ctx,
|
ctx,
|
||||||
a,
|
a,
|
||||||
|
Loading…
Reference in New Issue
Block a user