MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / drawSlots

Method drawSlots

src/LGraphNode.ts:3672–3706  ·  view source on GitHub ↗

* Draws the node's input and output slots.

(ctx: CanvasRenderingContext2D, {
    fromSlot,
    colorContext,
    editorAlpha,
    lowQuality,
  }: DrawSlotsOptions)

Source from the content-addressed store, hash-verified

3670 * Draws the node's input and output slots.
3671 */
3672 drawSlots(ctx: CanvasRenderingContext2D, {
3673 fromSlot,
3674 colorContext,
3675 editorAlpha,
3676 lowQuality,
3677 }: DrawSlotsOptions) {
3678 for (const slot of [...this.#concreteInputs, ...this.#concreteOutputs]) {
3679 const isValidTarget = fromSlot && slot.isValidTarget(fromSlot)
3680 const isMouseOverSlot = this.#isMouseOverSlot(slot)
3681
3682 // change opacity of incompatible slots when dragging a connection
3683 const isValid = !fromSlot || isValidTarget
3684 const highlight = isValid && isMouseOverSlot
3685
3686 // Show slot if it's not a widget input slot
3687 // or if it's a widget input slot and satisfies one of the following:
3688 // - the mouse is over the widget
3689 // - the slot is valid during link drop
3690 // - the slot is connected
3691 if (
3692 isMouseOverSlot ||
3693 isValidTarget ||
3694 !slot.isWidgetInputSlot ||
3695 this.#isMouseOverWidget(this.getWidgetFromSlot(slot)) ||
3696 slot.isConnected
3697 ) {
3698 ctx.globalAlpha = isValid ? editorAlpha : 0.4 * editorAlpha
3699 slot.draw(ctx, {
3700 colorContext,
3701 lowQuality,
3702 highlight,
3703 })
3704 }
3705 }
3706 }
3707
3708 /**
3709 * Arranges the node's widgets vertically.

Callers

nothing calls this directly

Calls 5

#isMouseOverSlotMethod · 0.95
#isMouseOverWidgetMethod · 0.95
getWidgetFromSlotMethod · 0.95
drawMethod · 0.65
isValidTargetMethod · 0.45

Tested by

no test coverage detected