去年就打算学着写写插件的,没想到在昨天发布的一个工作流中被迫写了一个,虽然只是一个转换数据格式的功能。
class AnyType(str):
"""A special type that can be connected to any other types. Credit to pythongosssss"""
def __ne__(self, __value: object) -> bool:
return False
any_type = AnyType("*")
# ---------------------------------------------------------------
class color2RGB:
# @乐皮ai 2024-05-09
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"colorDEC": ("STRING", {"forceInput": True}),
},
}
RETURN_TYPES = (any_type, any_type, any_type, )
RETURN_NAMES = ("R", "G", "B", )
FUNCTION = "split"
CATEGORY = "utils"
def split(self, colorDEC):
tulpeSn = list(colorDEC)
strings = [part for part in tulpeSn[:3]]
R, G, B, = strings + [""] * (3 - len(strings))
return (R, G, B, )
NODE_CLASS_MAPPINGS = {
"color2RGB": color2RGB
}
有两个类,一个是公共方法,这个是借用了pythongosssss写的接收任意类型数据的。 color2rgb就是一个节点了,完成后把节点丢到了utils菜单里面。 主要的功能是将RGB色拆分成三个值,更好为imagetextoutlined这个节点使用,使用场景其实并不大,但是没有这个反而挺烦人的,谁记得住RGB这些数值呢,相信这些写插件的大神应该会在后期迭代进去的。
插件地址:https://github.com/vxinhao/color2rgb