The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
automatic calculation of image pos from widgets
pythongosssss7e51bbd07f80
diff --git a/web/scripts/app.js b/web/scripts/app.jsindex ada1708dc..f0c0f9de4 100644--- a/web/scripts/app.js+++ b/web/scripts/app.js@@ -263,6 +263,34 @@ export class ComfyApp {*/#addDrawBackgroundHandler(node) {const app = this;++ function getImageTop(node) {+ let shiftY;+ if (node.imageOffset != null) {+ shiftY = node.imageOffset;+ } else {+ if (node.widgets?.length) {+ const w = node.widgets[node.widgets.length - 1];+ shiftY = w.last_y;+ if (w.computeSize) {+ shiftY += w.computeSize()[1] + 4;+ } else {+ shiftY += LiteGraph.NODE_WIDGET_HEIGHT + 4;+ }+ } else {+ shiftY = node.computeSize()[1];+ }+ }+ return shiftY;+ }++ node.prototype.setSizeForImage = function () {+ const minHeight = getImageTop(this) + 220;+ if (this.size[1] < minHeight) {+ this.setSize([this.size[0], minHeight]);+ }+ };+node.prototype.onDrawBackground = function (ctx) {if (!this.flags.collapsed) {const output = app.nodeOutputs[this.id + ""];@@ -283,9 +311,7 @@ export class ComfyApp {).then((imgs) => {if (this.images === output.images) {this.imgs = imgs.filter(Boolean);- if (this.size[1] < 100) {- this.size[1] = 250;- }+ this.setSizeForImage?.();app.graph.setDirtyCanvas(true);}});@@ -310,12 +336,7 @@ export class ComfyApp {this.imageIndex = imageIndex = 0;}- let shiftY;- if (this.imageOffset != null) {- shiftY = this.imageOffset;- } else {- shiftY = this.computeSize()[1];- }+ const shiftY = getImageTop(this);let dw = this.size[0];let dh = this.size[1];diff --git a/web/scripts/widgets.js b/web/scripts/widgets.jsindex c0e73ffa1..cd471bc93 100644--- a/web/scripts/widgets.js+++ b/web/scripts/widgets.js@@ -261,20 +261,13 @@ export const ComfyWidgets = {let uploadWidget;function showImage(name) {- // Position the image somewhere sensible- if (!node.imageOffset) {- node.imageOffset = uploadWidget.last_y ? uploadWidget.last_y + 25 : 75;- }-const img = new Image();img.onload = () => {node.imgs = [img];app.graph.setDirtyCanvas(true);};img.src = `/view?filename=${name}&type=input`;- if ((node.size[1] - node.imageOffset) < 100) {- node.size[1] = 250 + node.imageOffset;- }+ node.setSizeForImage?.();}// Add our own callback to the combo widget to render an image when it changes