Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

assign link_type_colors directly

EllangoK53fba56ee5fa
diff --git a/web/extensions/core/colorPalette.js b/web/extensions/core/colorPalette.js
index c1473b93f..a08d46684 100644
--- a/web/extensions/core/colorPalette.js
+++ b/web/extensions/core/colorPalette.js
@@ -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
- );
- };
-}