Draw canvas image preview in a widget (#2952)

This commit is contained in:
Chenlei Hu
2025-03-09 21:56:50 -04:00
committed by GitHub
parent 60022134ed
commit ec013cc511
9 changed files with 355 additions and 264 deletions

View File

@@ -1,10 +1,5 @@
import type { ColorOption } from '@comfyorg/litegraph'
import {
LGraphGroup,
LGraphNode,
LiteGraph,
isColorable
} from '@comfyorg/litegraph'
import { LGraphGroup, LGraphNode, isColorable } from '@comfyorg/litegraph'
import type { IComboWidget } from '@comfyorg/litegraph/dist/types/widgets'
import _ from 'lodash'
@@ -75,23 +70,3 @@ export function executeWidgetsCallback(
}
}
}
export function getImageTop(node: LGraphNode) {
let shiftY: number
if (node.imageOffset != null) {
return node.imageOffset
} else if (node.widgets?.length) {
const w = node.widgets[node.widgets.length - 1]
shiftY = w.last_y ?? 0
if (w.computeSize) {
shiftY += w.computeSize()[1] + 4
} else if (w.computedHeight) {
shiftY += w.computedHeight
} else {
shiftY += LiteGraph.NODE_WIDGET_HEIGHT + 4
}
} else {
return node.computeSize()[1]
}
return shiftY
}