added textsplit node
This commit is contained in:
+33
-5
@@ -1001,7 +1001,39 @@ class ImageAddText:
|
|||||||
|
|
||||||
|
|
||||||
return (image,mask.unsqueeze(0),text,)
|
return (image,mask.unsqueeze(0),text,)
|
||||||
|
|
||||||
|
class TextSplit:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {
|
||||||
|
"required":{
|
||||||
|
"text":("STRING",{"default":"","forceInput": True},),
|
||||||
|
"separator":("STRING",{"default":"."},),
|
||||||
|
"reverse": ([False,True],),
|
||||||
|
"return_half":(["First Half","Second Half"],),
|
||||||
|
},}
|
||||||
|
RETURN_TYPES = ("STRING",)
|
||||||
|
RETURN_NAMES = ("text",)
|
||||||
|
OUTPUT_NODE = True
|
||||||
|
FUNCTION = "dosplit"
|
||||||
|
CATEGORY = "Chibi-Nodes/Text"
|
||||||
|
|
||||||
|
def dosplit(self, text,separator,reverse,return_half):
|
||||||
|
if reverse == True:
|
||||||
|
text = text.rsplit(separator,1)
|
||||||
|
if reverse == False:
|
||||||
|
text = text.split(separator,1)
|
||||||
|
|
||||||
|
if len(text) == 2:
|
||||||
|
if return_half == "First Half":
|
||||||
|
text = text[0]
|
||||||
|
if return_half == "Second Half":
|
||||||
|
text = text[1]
|
||||||
|
|
||||||
|
return (text,)
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"Loader":Loader,
|
"Loader":Loader,
|
||||||
@@ -1012,17 +1044,13 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"LoadEmbedding": LoadEmbedding,
|
"LoadEmbedding": LoadEmbedding,
|
||||||
"ConditionText": ConditionText,
|
"ConditionText": ConditionText,
|
||||||
"ConditionTextMulti": ConditionTextMulti,
|
"ConditionTextMulti": ConditionTextMulti,
|
||||||
|
|
||||||
"Textbox":Textbox,
|
"Textbox":Textbox,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"ImageSizeInfo" : ImageSizeInfo,
|
"ImageSizeInfo" : ImageSizeInfo,
|
||||||
"ImageSimpleResize" : ImageSimpleResize,
|
"ImageSimpleResize" : ImageSimpleResize,
|
||||||
"ImageAddText" : ImageAddText,
|
"ImageAddText" : ImageAddText,
|
||||||
|
|
||||||
"Int2String": Int2String,
|
"Int2String": Int2String,
|
||||||
"LoadImageExtended": LoadImageExtended,
|
"LoadImageExtended": LoadImageExtended,
|
||||||
"SeedGenerator" : SeedGenerator,
|
"SeedGenerator" : SeedGenerator,
|
||||||
"SaveImages":SaveImages,
|
"SaveImages":SaveImages,
|
||||||
|
"TextSplit": TextSplit,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user