diff --git a/README.md b/README.md index eacb861..b8812d7 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,18 @@ Use Cases: - Preparing text for text-to-image generation - Standardizing text input format +Parameter Settings: +![Parameter Settings](docment/images/rm_line_and_space_cn01.png) + +Example with keep_single_empty_line=True: +![Keep Single Empty Line](docment/images/rm_line_and_space_cn02.png) + +Example with preserve_indentation=True: +![Preserve Indentation](docment/images/rm_line_and_space_cn03.png) + +Example with trim_trailing_spaces=True: +![Trim Trailing Spaces](docment/images/rm_line_and_space_cn04.png) + ## 📝 License MIT License diff --git a/README_CN.md b/README_CN.md index dacd1dd..ebb58ef 100644 --- a/README_CN.md +++ b/README_CN.md @@ -86,6 +86,18 @@ - 准备文生图的输入文本 - 标准化文本输入格式 +参数设置: +![参数设置](docment/images/rm_line_and_space_cn01.png) + +保留单个空行的示例: +![保留单个空行](docment/images/rm_line_and_space_cn02.png) + +保留缩进的示例: +![保留缩进](docment/images/rm_line_and_space_cn03.png) + +移除尾随空格的示例: +![移除尾随空格](docment/images/rm_line_and_space_cn04.png) + ## 📝 许可证 MIT License diff --git a/__init__.py b/__init__.py index d120fd4..6c6bec8 100644 --- a/__init__.py +++ b/__init__.py @@ -4,21 +4,20 @@ setup() try: from .image_resolution_adjuster import ImageResolutionAdjuster - # 暂时注释掉未实现的节点 - # from .dynamic_image_input import DynamicImageInputs + from .color_picker import ColorPicker from .remove_empty_lines import RemoveEmptyLinesAndLeadingSpaces # 节点映射 NODE_CLASS_MAPPINGS = { "ImageResolutionAdjuster": ImageResolutionAdjuster, - # "DynamicImageInputs": DynamicImageInputs, - "RemoveEmptyLinesAndLeadingSpaces": RemoveEmptyLinesAndLeadingSpaces, + "ColorPicker": ColorPicker, + "RemoveEmptyLinesAndLeadingSpaces": RemoveEmptyLinesAndLeadingSpaces } NODE_DISPLAY_NAME_MAPPINGS = { "ImageResolutionAdjuster": "Image Resolution Adjuster", - # "DynamicImageInputs": "Dynamic Image Inputs", - "RemoveEmptyLinesAndLeadingSpaces": "Remove Empty Lines And LeadingSpaces", + "ColorPicker": "Color Picker", + "RemoveEmptyLinesAndLeadingSpaces": "Remove Empty Lines And Leading Spaces" } except ImportError as e: print(f"Error importing modules: {e}") diff --git a/__pycache__/__init__.cpython-311.pyc b/__pycache__/__init__.cpython-311.pyc index 367435d..ce9fecb 100644 Binary files a/__pycache__/__init__.cpython-311.pyc and b/__pycache__/__init__.cpython-311.pyc differ diff --git a/__pycache__/color_picker.cpython-311.pyc b/__pycache__/color_picker.cpython-311.pyc new file mode 100644 index 0000000..ec2a242 Binary files /dev/null and b/__pycache__/color_picker.cpython-311.pyc differ diff --git a/color_picker.py b/color_picker.py new file mode 100644 index 0000000..f68c412 --- /dev/null +++ b/color_picker.py @@ -0,0 +1,44 @@ +import torch +import numpy as np +from PIL import Image + +class ColorPicker: + """ + 颜色选择器节点,使用 jscolor 实现颜色选择和吸管工具 + """ + + def __init__(self): + self.color = "#000000" + + @classmethod + def INPUT_TYPES(s): + return {"required": {}} # 不需要输入项 + + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("color",) + FUNCTION = "pick_color" + CATEGORY = "🎨Painting👓Coder/🎨Color" + + def pick_color(self): + return (self.color,) + + @classmethod + def VALIDATE_INPUTS(s, **kwargs): + return True + + def widget_value_updated(self, widget, value): + if widget.name == "color_picker": + self.color = value + + @classmethod + def WIDGETS(s): + return {"color_picker": ("color", {"default": "#000000"})} + +# 在 __init__.py 中添加节点注册 +NODE_CLASS_MAPPINGS = { + "ColorPicker": ColorPicker +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "ColorPicker": "Color Picker" +} \ No newline at end of file diff --git a/docment/images/rm_line_and_space_cn01.png b/docment/images/rm_line_and_space_cn01.png new file mode 100644 index 0000000..0fd969c Binary files /dev/null and b/docment/images/rm_line_and_space_cn01.png differ diff --git a/docment/images/rm_line_and_space_cn02.png b/docment/images/rm_line_and_space_cn02.png new file mode 100644 index 0000000..6b849e2 Binary files /dev/null and b/docment/images/rm_line_and_space_cn02.png differ diff --git a/docment/images/rm_line_and_space_cn03.png b/docment/images/rm_line_and_space_cn03.png new file mode 100644 index 0000000..bf3d948 Binary files /dev/null and b/docment/images/rm_line_and_space_cn03.png differ diff --git a/docment/images/rm_line_and_space_cn04.png b/docment/images/rm_line_and_space_cn04.png new file mode 100644 index 0000000..922497d Binary files /dev/null and b/docment/images/rm_line_and_space_cn04.png differ