mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
Fix drawing img on collapsed nodes
This commit is contained in:
parent
d4486f8284
commit
b6487b3ec9
@ -265,39 +265,41 @@ function onObjectInfo(json) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MyNode.prototype.onDrawBackground = function(ctx) {
|
MyNode.prototype.onDrawBackground = function(ctx) {
|
||||||
const output = nodeOutputs[this.id + ""];
|
if(!this.flags.collapsed) {
|
||||||
if(output && output.images) {
|
const output = nodeOutputs[this.id + ""];
|
||||||
const src = output.images[0];
|
if(output && output.images) {
|
||||||
if(this.src !== src) {
|
const src = output.images[0];
|
||||||
this.img = null;
|
if(this.src !== src) {
|
||||||
this.src = src;
|
this.img = null;
|
||||||
const img = new Image();
|
this.src = src;
|
||||||
img.src = "/view/" + src;
|
const img = new Image();
|
||||||
img.onload = () => {
|
img.src = "/view/" + src;
|
||||||
graph.setDirtyCanvas(true);
|
img.onload = () => {
|
||||||
this.img = img;
|
graph.setDirtyCanvas(true);
|
||||||
if(this.size[1] < 100) {
|
this.img = img;
|
||||||
this.size[1] = 250;
|
if(this.size[1] < 100) {
|
||||||
|
this.size[1] = 250;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if(this.img) {
|
||||||
if(this.img) {
|
let w = this.img.naturalWidth;
|
||||||
let w = this.img.naturalWidth;
|
let h = this.img.naturalHeight;
|
||||||
let h = this.img.naturalHeight;
|
let dw = this.size[0];
|
||||||
let dw = this.size[0];
|
let dh = this.size[1];
|
||||||
let dh = this.size[1];
|
|
||||||
|
|
||||||
const scaleX = dw / w;
|
const scaleX = dw / w;
|
||||||
const scaleY = dh / h;
|
const scaleY = dh / h;
|
||||||
const scale = Math.min(scaleX, scaleY, 1);
|
const scale = Math.min(scaleX, scaleY, 1);
|
||||||
|
|
||||||
w *= scale;
|
w *= scale;
|
||||||
h *= scale;
|
h *= scale;
|
||||||
|
|
||||||
let x = (dw - w) / 2;
|
let x = (dw - w) / 2;
|
||||||
let y = (dh - h) / 2;
|
let y = (dh - h) / 2;
|
||||||
|
|
||||||
ctx.drawImage(this.img, x, y, w, h);
|
ctx.drawImage(this.img, x, y, w, h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user