* Gets the position of an output slot, in graph co-ordinates. * * This method is preferred over the legacy getConnectionPos method. * @param slot Output slot index * @returns Position of the output slot
(slot: number)
| 3077 | * @returns Position of the output slot |
| 3078 | */ |
| 3079 | getOutputPos(slot: number): Point { |
| 3080 | const { pos: [nodeX, nodeY], outputs, size: [width] } = this |
| 3081 | |
| 3082 | if (this.flags.collapsed) { |
| 3083 | const width = this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH |
| 3084 | const halfTitle = LiteGraph.NODE_TITLE_HEIGHT * 0.5 |
| 3085 | return [nodeX + width, nodeY - halfTitle] |
| 3086 | } |
| 3087 | |
| 3088 | const outputPos = outputs?.[slot]?.pos |
| 3089 | if (outputPos) return [nodeX + outputPos[0], nodeY + outputPos[1]] |
| 3090 | |
| 3091 | // default vertical slots |
| 3092 | const offsetX = LiteGraph.NODE_SLOT_HEIGHT * 0.5 |
| 3093 | const nodeOffsetY = this.constructor.slot_start_y || 0 |
| 3094 | const slotIndex = this.#defaultVerticalOutputs.indexOf(this.outputs[slot]) |
| 3095 | const slotY = (slotIndex + 0.7) * LiteGraph.NODE_SLOT_HEIGHT |
| 3096 | |
| 3097 | // TODO: Why +1? |
| 3098 | return [nodeX + width + 1 - offsetX, nodeY + slotY + nodeOffsetY] |
| 3099 | } |
| 3100 | |
| 3101 | /** @inheritdoc */ |
| 3102 | snapToGrid(snapTo: number): boolean { |
no outgoing calls