Ai
1 Star 0 Fork 1

ComfyUI CustomNodes Clone/ComfyUI-Custom-Scripts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
swapResolution.js 872 Bytes
一键复制 编辑 原始数据 按行查看 历史
pythongosssss 提交于 2023-10-01 17:40 +08:00 . Add swap width/height
import { app } from "../../../scripts/app.js";
app.registerExtension({
name: "pysssss.SwapResolution",
async beforeRegisterNodeDef(nodeType, nodeData) {
const inputs = { ...nodeData.input?.required, ...nodeData.input?.optional };
if (inputs.width && inputs.height) {
const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions;
nodeType.prototype.getExtraMenuOptions = function (_, options) {
const r = origGetExtraMenuOptions?.apply?.(this, arguments);
options.push(
{
content: "Swap width/height",
callback: () => {
const w = this.widgets.find((w) => w.name === "width");
const h = this.widgets.find((w) => w.name === "height");
const a = w.value;
w.value = h.value;
h.value = a;
app.graph.setDirtyCanvas(true);
},
},
null
);
return r;
};
}
},
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/custom_nodes_clone/ComfyUI-Custom-Scripts.git
git@gitee.com:custom_nodes_clone/ComfyUI-Custom-Scripts.git
custom_nodes_clone
ComfyUI-Custom-Scripts
ComfyUI-Custom-Scripts
main

搜索帮助