Skip to content

Commit 27a3fa6

Browse files
committed
feat(color): allow coloring roup and child nodes
1 parent c1350f6 commit 27a3fa6

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,19 @@ Colors a node depending on the node title (case-insensitive).
112112

113113
- Colors > Custom (only works in Color Mode: "default")
114114

115+
![image](https://github.com/failfa-st/failfast-comfyui-extensions/assets/1148334/f0c4dc53-0e40-480d-a3f9-09b50a3ab56d)
116+
115117
**Groups**
116118

117119
- Edit group > Color > Custom
118-
- Edit group > freeze/unfreeze (pins group and child nodes)
120+
- Edit group > Color > Color all (colors Group and child Nodes)
121+
- Edit group > freeze/unfreeze (pins Group and child Nodes)
119122

120123
![image](https://github.com/failfa-st/hyv/assets/1148334/7558fcfb-1733-4d78-904b-50891f29fa68)
121124

122-
**Screenshot from Nodes (similar for Groups)**
125+
**Colors**
123126

124-
![image](https://github.com/failfa-st/failfast-comfyui-extensions/assets/1148334/657d1a6c-d4d9-4091-9a35-16fa9ca50489)
127+
![image](https://github.com/failfa-st/failfast-comfyui-extensions/assets/1148334/c43c2c7b-1eb5-4827-ba10-c53cc1b58100)
125128

126129

127130
**Canvas**

extensions/colors.js

+43
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ app.registerExtension({
279279
LGraphCanvas.onMenuNodeColors = function (value, options, e, menu, node) {
280280
const response = onMenuNodeColors.apply(this, arguments);
281281
const menuRoot = menu.current_submenu.root;
282+
const isGroup = node instanceof LGraphGroup;
283+
282284
menuRoot.append(
283285
$el("div.litemenu-entry.submenu", [
284286
$el(
@@ -313,6 +315,47 @@ app.registerExtension({
313315
),
314316
]),
315317
);
318+
if (isGroup) {
319+
menuRoot.append(
320+
$el("div.litemenu-entry.submenu", [
321+
$el(
322+
"label",
323+
{
324+
style: {
325+
position: "relative",
326+
overflow: "hidden",
327+
display: "block",
328+
paddingLeft: "4px",
329+
borderLeft: "8px solid #222",
330+
},
331+
},
332+
[
333+
"Color all",
334+
$el("input", {
335+
type: "color",
336+
style: {
337+
position: "absolute",
338+
right: "200%",
339+
},
340+
oninput(event) {
341+
node.recomputeInsideNodes();
342+
node.bgcolor = event.target.value;
343+
node.color = shadeHexColor(node.bgcolor);
344+
node._nodes.forEach((node_) => {
345+
node_.bgcolor = node.bgcolor;
346+
node_.color = node.color;
347+
});
348+
// TODO: check if we can adjust this
349+
// node.title_color = getContrastColor(node.bgcolor);
350+
351+
node.setDirtyCanvas(true, true);
352+
},
353+
}),
354+
],
355+
),
356+
]),
357+
);
358+
}
316359
return response;
317360
};
318361
app.ui.settings.addSetting({

0 commit comments

Comments
 (0)