Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
53fba56e
Commit
53fba56e
authored
Apr 08, 2023
by
EllangoK
Browse files
assign link_type_colors directly
parent
d9220a0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
62 deletions
+1
-62
web/extensions/core/colorPalette.js
web/extensions/core/colorPalette.js
+1
-62
No files found.
web/extensions/core/colorPalette.js
View file @
53fba56e
...
...
@@ -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
);
};
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment