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
0d358b95
"examples/git@developer.sourcefind.cn:hehl2/torchaudio.git" did not exist on "19f53cf249d69c81be3005d582d37530f0a3aef7"
Commit
0d358b95
authored
Apr 08, 2023
by
EllangoK
Browse files
cleanup customizeRenderLink
parent
6b638c96
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
70 deletions
+57
-70
web/extensions/core/colorPalette.js
web/extensions/core/colorPalette.js
+57
-70
No files found.
web/extensions/core/colorPalette.js
View file @
0d358b95
...
@@ -250,76 +250,7 @@ app.registerExtension({
...
@@ -250,76 +250,7 @@ app.registerExtension({
}
}
}
}
}
}
customizeRenderLink
(
colorPalette
);
(
function
(
colorPalette
)
{
var
LGraphCanvas
=
LiteGraph
.
LGraphCanvas
;
var
LGraph
=
LiteGraph
.
LGraph
;
// Save the original renderLink function
var
originalRenderLink
=
LGraphCanvas
.
prototype
.
renderLink
;
// Override the renderLink function
LGraphCanvas
.
prototype
.
renderLink
=
function
(
ctx
,
a
,
b
,
link
,
skip_border
,
flow
,
color
,
start_dir
,
end_dir
,
num_sublines
)
{
if
(
link
&&
link
.
color
)
{
color
=
link
.
color
;
}
if
(
link
)
{
const
inputNode
=
this
.
graph
.
getNodeById
(
link
.
origin_id
);
const
outputNode
=
this
.
graph
.
getNodeById
(
link
.
target_id
);
let
data
=
null
;
if
(
inputNode
.
outputs
.
length
>
1
)
{
data
=
outputNode
.
inputs
[
0
];
}
else
{
data
=
inputNode
.
outputs
[
0
];
}
const
matchingEntry
=
inputNode
.
outputs
.
find
(
output
=>
{
return
outputNode
.
inputs
.
some
(
input
=>
input
.
type
===
output
.
type
);
});
console
.
log
(
"
matchingEntry:
"
,
matchingEntry
)
const
inputTypes
=
inputNode
.
outputs
.
map
(
output
=>
output
.
type
);
console
.
log
(
"
Input types:
"
,
inputTypes
);
const
outputTypes
=
outputNode
.
inputs
.
map
(
input
=>
input
.
type
);
console
.
log
(
"
Output types:
"
,
outputTypes
);
let
nodeType
=
matchingEntry
.
type
;
color
=
"
#
"
+
Math
.
floor
(
Math
.
random
()
*
16777215
).
toString
(
16
);
color
=
colorPalette
.
colors
.
node_slot
[
nodeType
];
}
// Call the original renderLink function with the new color
originalRenderLink
.
call
(
this
,
ctx
,
a
,
b
,
link
,
skip_border
,
flow
,
color
,
start_dir
,
end_dir
,
num_sublines
);
};
})(
colorPalette
);
app
.
canvas
.
draw
(
true
,
true
);
app
.
canvas
.
draw
(
true
,
true
);
}
}
};
};
...
@@ -476,3 +407,59 @@ app.registerExtension({
...
@@ -476,3 +407,59 @@ app.registerExtension({
});
});
},
},
});
});
function
customizeRenderLink
(
colorPalette
)
{
var
LGraphCanvas
=
LiteGraph
.
LGraphCanvas
;
function
getLinkColor
(
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
;
}
var
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
=
getLinkColor
(
link
,
inputNode
,
outputNode
,
colorPalette
);
}
originalRenderLink
.
call
(
this
,
ctx
,
a
,
b
,
link
,
skip_border
,
flow
,
color
,
start_dir
,
end_dir
,
num_sublines
);
};
}
\ No newline at end of file
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