add ComfyUI-darkHUB custom node
Browse files- .gitattributes +1 -0
- ComfyUI-darkHUB/__init__.py +5 -0
- ComfyUI-darkHUB/js/darkHUBcreator.png +3 -0
- ComfyUI-darkHUB/js/image_note.js +147 -0
- ComfyUI-darkHUB/nodes.py +24 -0
.gitattributes
CHANGED
|
@@ -367,3 +367,4 @@ v3-nodes/ComfyUI-WanVideoWrapper/example_workflows/example_inputs/woman.wav filt
|
|
| 367 |
ComfyUI_Oz/fonts/BricolageGrotesque.ttf filter=lfs diff=lfs merge=lfs -text
|
| 368 |
ComfyUI_Oz/js/Instara_loader.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 369 |
ComfyUI_Oz/nodes/utility_nodes/_refs/iphone13.jpg filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 367 |
ComfyUI_Oz/fonts/BricolageGrotesque.ttf filter=lfs diff=lfs merge=lfs -text
|
| 368 |
ComfyUI_Oz/js/Instara_loader.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 369 |
ComfyUI_Oz/nodes/utility_nodes/_refs/iphone13.jpg filter=lfs diff=lfs merge=lfs -text
|
| 370 |
+
ComfyUI-darkHUB/js/darkHUBcreator.png filter=lfs diff=lfs merge=lfs -text
|
ComfyUI-darkHUB/__init__.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
|
| 2 |
+
|
| 3 |
+
WEB_DIRECTORY = "./js"
|
| 4 |
+
|
| 5 |
+
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
|
ComfyUI-darkHUB/js/darkHUBcreator.png
ADDED
|
Git LFS Details
|
ComfyUI-darkHUB/js/image_note.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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H = 32;
|
| 9 |
+
|
| 10 |
+
// Juda katta rasmlar uchun limit
|
| 11 |
+
const MAX_IMG_W = 390;
|
| 12 |
+
const MAX_IMG_H = 390;
|
| 13 |
+
|
| 14 |
+
// Placeholder
|
| 15 |
+
const PLACEHOLDER_W = 220;
|
| 16 |
+
const PLACEHOLDER_H = 220;
|
| 17 |
+
|
| 18 |
+
function fitContain(srcW, srcH, maxW, maxH) {
|
| 19 |
+
const scale = Math.min(maxW / srcW, maxH / srcH, 1);
|
| 20 |
+
return {
|
| 21 |
+
w: Math.max(1, Math.round(srcW * scale)),
|
| 22 |
+
h: Math.max(1, Math.round(srcH * scale)),
|
| 23 |
+
};
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function getWidget(node, name) {
|
| 27 |
+
return node.widgets?.find((w) => w.name === name);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function hideWidget(node, name) {
|
| 31 |
+
const w = getWidget(node, name);
|
| 32 |
+
if (!w) return;
|
| 33 |
+
w.type = 'hidden';
|
| 34 |
+
w.hidden = true;
|
| 35 |
+
w.computeSize = () => [0, 0];
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
function updateNodeSize(node) {
|
| 39 |
+
if (!node._img || !node._img.naturalWidth || !node._img.naturalHeight) {
|
| 40 |
+
const nodeW = PLACEHOLDER_W;
|
| 41 |
+
const nodeH = TITLE_H + PLACEHOLDER_H;
|
| 42 |
+
|
| 43 |
+
if (node.setSize) node.setSize([nodeW, nodeH]);
|
| 44 |
+
else node.size = [nodeW, nodeH];
|
| 45 |
+
|
| 46 |
+
node._drawW = PLACEHOLDER_W;
|
| 47 |
+
node._drawH = PLACEHOLDER_H;
|
| 48 |
+
return;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
const fit = fitContain(node._img.naturalWidth, node._img.naturalHeight, MAX_IMG_W, MAX_IMG_H);
|
| 52 |
+
|
| 53 |
+
node._drawW = fit.w;
|
| 54 |
+
node._drawH = fit.h;
|
| 55 |
+
|
| 56 |
+
// Endi hech qanday yon/past padding yo'q
|
| 57 |
+
const nodeW = fit.w;
|
| 58 |
+
const nodeH = TITLE_H + fit.h;
|
| 59 |
+
|
| 60 |
+
if (node.setSize) node.setSize([nodeW, nodeH]);
|
| 61 |
+
else node.size = [nodeW, nodeH];
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
app.registerExtension({
|
| 65 |
+
name: 'comfy.darkhub.static_image.no_padding',
|
| 66 |
+
|
| 67 |
+
async beforeRegisterNodeDef(nodeType, nodeData) {
|
| 68 |
+
if (nodeType.comfyClass !== TARGET_CLASS) return;
|
| 69 |
+
|
| 70 |
+
const onNodeCreated = nodeType.prototype.onNodeCreated;
|
| 71 |
+
nodeType.prototype.onNodeCreated = function () {
|
| 72 |
+
const r = onNodeCreated?.apply(this, arguments);
|
| 73 |
+
|
| 74 |
+
this.serialize_widgets = true;
|
| 75 |
+
this.resizable = false;
|
| 76 |
+
|
| 77 |
+
this._img = null;
|
| 78 |
+
this._imgLoaded = false;
|
| 79 |
+
this._imgError = false;
|
| 80 |
+
this._drawW = PLACEHOLDER_W;
|
| 81 |
+
this._drawH = PLACEHOLDER_H;
|
| 82 |
+
|
| 83 |
+
hideWidget(this, 'image_data');
|
| 84 |
+
hideWidget(this, 'caption');
|
| 85 |
+
hideWidget(this, 'box_width');
|
| 86 |
+
hideWidget(this, 'box_height');
|
| 87 |
+
|
| 88 |
+
updateNodeSize(this);
|
| 89 |
+
|
| 90 |
+
this._img = new Image();
|
| 91 |
+
|
| 92 |
+
this._img.onload = () => {
|
| 93 |
+
this._imgLoaded = true;
|
| 94 |
+
this._imgError = false;
|
| 95 |
+
updateNodeSize(this);
|
| 96 |
+
this.setDirtyCanvas(true, true);
|
| 97 |
+
};
|
| 98 |
+
|
| 99 |
+
this._img.onerror = (err) => {
|
| 100 |
+
console.error('darkHUB image load error:', STATIC_IMAGE, err);
|
| 101 |
+
this._imgLoaded = false;
|
| 102 |
+
this._imgError = true;
|
| 103 |
+
updateNodeSize(this);
|
| 104 |
+
this.setDirtyCanvas(true, true);
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
this._img.src = STATIC_IMAGE;
|
| 108 |
+
|
| 109 |
+
return r;
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
const onDrawBackground = nodeType.prototype.onDrawBackground;
|
| 113 |
+
nodeType.prototype.onDrawBackground = function (ctx) {
|
| 114 |
+
const r = onDrawBackground?.apply(this, arguments);
|
| 115 |
+
|
| 116 |
+
const w = this._drawW || PLACEHOLDER_W;
|
| 117 |
+
const h = this._drawH || PLACEHOLDER_H;
|
| 118 |
+
|
| 119 |
+
// Rasm title bar tagidan boshlanadi
|
| 120 |
+
const x = 0;
|
| 121 |
+
const y = TITLE_H;
|
| 122 |
+
|
| 123 |
+
ctx.save();
|
| 124 |
+
|
| 125 |
+
if (this._img && this._imgLoaded && this._img.naturalWidth > 0) {
|
| 126 |
+
// Hech qanday bo'shliqsiz
|
| 127 |
+
ctx.drawImage(this._img, x, y, w, h);
|
| 128 |
+
} else {
|
| 129 |
+
ctx.fillStyle = '#05070d';
|
| 130 |
+
ctx.fillRect(x, y, w, h);
|
| 131 |
+
|
| 132 |
+
ctx.fillStyle = '#9aa4b2';
|
| 133 |
+
ctx.font = '14px sans-serif';
|
| 134 |
+
ctx.textAlign = 'center';
|
| 135 |
+
ctx.textBaseline = 'middle';
|
| 136 |
+
ctx.fillText(
|
| 137 |
+
this._imgError ? 'Rasm yuklanmadi' : 'Rasm yuklanmoqda...',
|
| 138 |
+
x + w / 2,
|
| 139 |
+
y + h / 2
|
| 140 |
+
);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
ctx.restore();
|
| 144 |
+
return r;
|
| 145 |
+
};
|
| 146 |
+
},
|
| 147 |
+
});
|
ComfyUI-darkHUB/nodes.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class darkHUB:
|
| 2 |
+
CATEGORY = "utils"
|
| 3 |
+
FUNCTION = "run"
|
| 4 |
+
RETURN_TYPES = ()
|
| 5 |
+
|
| 6 |
+
@classmethod
|
| 7 |
+
def INPUT_TYPES(cls):
|
| 8 |
+
return {
|
| 9 |
+
"required": {
|
| 10 |
+
"image_data": ("STRING", {"default": "", "multiline": True}),
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
def run(self, image_data):
|
| 15 |
+
return ()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
NODE_CLASS_MAPPINGS = {
|
| 19 |
+
"darkHUB": darkHUB,
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
| 23 |
+
"darkHUB": "dark HUB",
|
| 24 |
+
}
|