From 53fba56ee5fa48261d8caec46927c34923a168fd Mon Sep 17 00:00:00 2001 From: EllangoK Date: Sat, 8 Apr 2023 13:18:23 -0400 Subject: [PATCH] assign link_type_colors directly --- web/extensions/core/colorPalette.js | 63 +---------------------------- 1 file changed, 1 insertion(+), 62 deletions(-) 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 - ); - }; -}