ing
This commit is contained in:
+2
-2
@@ -268,7 +268,7 @@ PromptServer.add_routes=new_add_routes
|
||||
|
||||
# 导入节点
|
||||
from .nodes.PromptNode import RandomPrompt
|
||||
from .nodes.ImageNode import TransparentImage,LoadImagesFromPath,TextImage,SvgImage,EmptyLayer,EditLayer,NewLayer,MergeLayers,AreaToMask,SmoothMask,FeatheredMask,SplitLongMask,ImageCropByAlpha,EnhanceImage,FaceToMask
|
||||
from .nodes.ImageNode import TransparentImage,LoadImagesFromPath,TextImage,SvgImage,EmptyLayer,ShowLayer,NewLayer,MergeLayers,AreaToMask,SmoothMask,FeatheredMask,SplitLongMask,ImageCropByAlpha,EnhanceImage,FaceToMask
|
||||
from .nodes.Vae import VAELoader,VAEDecode
|
||||
from .nodes.ScreenShareNode import ScreenShareNode,FloatingVideo
|
||||
from .nodes.Clipseg import CLIPSeg,CombineMasks
|
||||
@@ -284,7 +284,7 @@ NODE_CLASS_MAPPINGS = {
|
||||
"EnhanceImage":EnhanceImage,
|
||||
"SvgImage":SvgImage,
|
||||
"EmptyLayer":EmptyLayer,
|
||||
# "EditLayer":EditLayer,
|
||||
"ShowLayer":ShowLayer,
|
||||
"NewLayer":NewLayer,
|
||||
"MergeLayers":MergeLayers,
|
||||
"SplitLongMask":SplitLongMask,
|
||||
|
||||
+24
-24
@@ -1115,7 +1115,7 @@ class NewLayer:
|
||||
return (layer_n,)
|
||||
|
||||
|
||||
class EditLayer:
|
||||
class ShowLayer:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
@@ -1159,46 +1159,46 @@ class EditLayer:
|
||||
"display": "number" # Cosmetic only: display as "number" or "slider"
|
||||
}),
|
||||
"scale_option": (["width","height",'overall'],),
|
||||
"image": ("IMAGE",),
|
||||
# "image": ("IMAGE",),
|
||||
},
|
||||
"optional":{
|
||||
"mask": ("MASK",{"default": None}),
|
||||
# "mask": ("MASK",{"default": None}),
|
||||
"layers": ("LAYER",{"default": None}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("LAYER",)
|
||||
RETURN_NAMES = ("layers",)
|
||||
RETURN_TYPES = ( )
|
||||
RETURN_NAMES = ( )
|
||||
|
||||
FUNCTION = "run"
|
||||
|
||||
CATEGORY = "♾️Mixlab/layer"
|
||||
|
||||
INPUT_IS_LIST = True
|
||||
OUTPUT_IS_LIST = (True,)
|
||||
# OUTPUT_IS_LIST = (True,)
|
||||
|
||||
def run(self,edit,x,y,width,height,z_index,scale_option,image,mask,layers):
|
||||
def run(self,edit,x,y,width,height,z_index,scale_option,layers):
|
||||
# print(x,y,width,height,z_index,image,mask)
|
||||
|
||||
if mask==None:
|
||||
im=tensor2pil(image)
|
||||
mask=im.convert('L')
|
||||
mask=pil2tensor(mask)
|
||||
else:
|
||||
mask=mask[0]
|
||||
# if mask==None:
|
||||
# im=tensor2pil(image)
|
||||
# mask=im.convert('L')
|
||||
# mask=pil2tensor(mask)
|
||||
# else:
|
||||
# mask=mask[0]
|
||||
|
||||
layers[edit[0]]={
|
||||
"x":x[0],
|
||||
"y":y[0],
|
||||
"width":width[0],
|
||||
"height":height[0],
|
||||
"z_index":z_index[0],
|
||||
"scale_option":scale_option[0],
|
||||
"image":image[0],
|
||||
"mask":mask
|
||||
}
|
||||
# layers[edit[0]]={
|
||||
# "x":x[0],
|
||||
# "y":y[0],
|
||||
# "width":width[0],
|
||||
# "height":height[0],
|
||||
# "z_index":z_index[0],
|
||||
# "scale_option":scale_option[0],
|
||||
# "image":image[0],
|
||||
# "mask":mask
|
||||
# }
|
||||
|
||||
return (layers,)
|
||||
return ( )
|
||||
|
||||
|
||||
class MergeLayers:
|
||||
|
||||
@@ -433,6 +433,10 @@ app.registerExtension({
|
||||
return onRemoved?.()
|
||||
}
|
||||
|
||||
if (this.onResize) {
|
||||
this.onResize(this.size)
|
||||
}
|
||||
|
||||
this.serialize_widgets = true //需要保存参数
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ const parseSvg = async svgContent => {
|
||||
}
|
||||
|
||||
app.registerExtension({
|
||||
name: 'Mixlab.layer.EditLayer',
|
||||
name: 'Mixlab.layer.ShowLayer',
|
||||
async getCustomWidgets (app) {
|
||||
return {
|
||||
EDIT (node, inputName, inputData, app) {
|
||||
@@ -159,7 +159,7 @@ app.registerExtension({
|
||||
if (this.input)
|
||||
Object.assign(
|
||||
this.input.style,
|
||||
get_position_style(ctx, widget_width, 66, node.size[1])
|
||||
get_position_style(ctx, widget_width, 32, node.size[1])
|
||||
)
|
||||
},
|
||||
computeSize (...args) {
|
||||
@@ -179,16 +179,16 @@ app.registerExtension({
|
||||
},
|
||||
|
||||
async beforeRegisterNodeDef (nodeType, nodeData, app) {
|
||||
if (nodeType.comfyClass == 'EditLayer') {
|
||||
if (nodeType.comfyClass == 'ShowLayer') {
|
||||
const orig_nodeCreated = nodeType.prototype.onNodeCreated
|
||||
nodeType.prototype.onNodeCreated = async function () {
|
||||
orig_nodeCreated?.apply(this, arguments)
|
||||
|
||||
const findNode = nodeId => {
|
||||
let node = app.graph._nodes_by_id[nodeId]
|
||||
if (node?.type == 'Reroute'||node?.type == 'EditLayer') {
|
||||
if (node?.type == 'Reroute') {
|
||||
|
||||
let linkId =node.inputs.filter(i=>i.type=='LAYER'||i.type=='*')[0].link
|
||||
let linkId =node.inputs.filter(i=>i.type=='*')[0].link
|
||||
nodeId = app.graph.links.filter(link => link.id == linkId)[0]
|
||||
?.origin_id
|
||||
return findNode(nodeId)
|
||||
|
||||
Reference in New Issue
Block a user