Added open image in new tab menu item

Shifted image down on SaveImage node
This commit is contained in:
pythongosssss 2023-02-25 18:19:42 +00:00 committed by GitHub
parent 8ca346b9e2
commit 23507882d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -264,6 +264,15 @@ function onObjectInfo(json) {
this.addInput(x, type); this.addInput(x, type);
} }
MyNode.prototype.getExtraMenuOptions = function(graph, options) {
if(this.img) {
options.unshift({
content: "Open Image",
callback: () => window.open(this.img.src, "_blank")
});
}
}
MyNode.prototype.onDrawBackground = function(ctx) { MyNode.prototype.onDrawBackground = function(ctx) {
if(!this.flags.collapsed) { if(!this.flags.collapsed) {
const output = nodeOutputs[this.id + ""]; const output = nodeOutputs[this.id + ""];
@ -287,6 +296,10 @@ function onObjectInfo(json) {
let h = this.img.naturalHeight; let h = this.img.naturalHeight;
let dw = this.size[0]; let dw = this.size[0];
let dh = this.size[1]; let dh = this.size[1];
if(this.type === "SaveImage") {
dh -= 55;
}
const scaleX = dw / w; const scaleX = dw / w;
const scaleY = dh / h; const scaleY = dh / h;
@ -298,6 +311,10 @@ function onObjectInfo(json) {
let x = (dw - w) / 2; let x = (dw - w) / 2;
let y = (dh - h) / 2; let y = (dh - h) / 2;
if(this.type === "SaveImage") {
y += 55;
}
ctx.drawImage(this.img, x, y, w, h); ctx.drawImage(this.img, x, y, w, h);
} }
} }