mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-04 18:50:29 +08:00
Add color type and Color to RGB Int node (#12145)
Some checks are pending
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Some checks are pending
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Execution Tests / test (macos-latest) (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
* add color type and color to rgb int node * review fix for allowing output --------- Co-authored-by: Jedrzej Kosinski <kosinkadink1@gmail.com>
This commit is contained in:
parent
0167653781
commit
8aabe2403e
@ -1146,6 +1146,20 @@ class ImageCompare(ComfyTypeI):
|
|||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
return super().as_dict()
|
return super().as_dict()
|
||||||
|
|
||||||
|
|
||||||
|
@comfytype(io_type="COLOR")
|
||||||
|
class Color(ComfyTypeIO):
|
||||||
|
Type = str
|
||||||
|
|
||||||
|
class Input(WidgetInput):
|
||||||
|
def __init__(self, id: str, display_name: str=None, optional=False, tooltip: str=None,
|
||||||
|
socketless: bool=True, advanced: bool=None, default: str="#ffffff"):
|
||||||
|
super().__init__(id, display_name, optional, tooltip, None, default, socketless, None, None, None, None, advanced)
|
||||||
|
self.default: str
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
return super().as_dict()
|
||||||
|
|
||||||
DYNAMIC_INPUT_LOOKUP: dict[str, Callable[[dict[str, Any], dict[str, Any], tuple[str, dict[str, Any]], str, list[str] | None], None]] = {}
|
DYNAMIC_INPUT_LOOKUP: dict[str, Callable[[dict[str, Any], dict[str, Any], tuple[str, dict[str, Any]], str, list[str] | None], None]] = {}
|
||||||
def register_dynamic_input_func(io_type: str, func: Callable[[dict[str, Any], dict[str, Any], tuple[str, dict[str, Any]], str, list[str] | None], None]):
|
def register_dynamic_input_func(io_type: str, func: Callable[[dict[str, Any], dict[str, Any], tuple[str, dict[str, Any]], str, list[str] | None], None]):
|
||||||
DYNAMIC_INPUT_LOOKUP[io_type] = func
|
DYNAMIC_INPUT_LOOKUP[io_type] = func
|
||||||
@ -2038,6 +2052,7 @@ __all__ = [
|
|||||||
"AnyType",
|
"AnyType",
|
||||||
"MultiType",
|
"MultiType",
|
||||||
"Tracks",
|
"Tracks",
|
||||||
|
"Color",
|
||||||
# Dynamic Types
|
# Dynamic Types
|
||||||
"MatchType",
|
"MatchType",
|
||||||
"DynamicCombo",
|
"DynamicCombo",
|
||||||
|
|||||||
42
comfy_extras/nodes_color.py
Normal file
42
comfy_extras/nodes_color.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
from typing_extensions import override
|
||||||
|
from comfy_api.latest import ComfyExtension, io
|
||||||
|
|
||||||
|
|
||||||
|
class ColorToRGBInt(io.ComfyNode):
|
||||||
|
@classmethod
|
||||||
|
def define_schema(cls) -> io.Schema:
|
||||||
|
return io.Schema(
|
||||||
|
node_id="ColorToRGBInt",
|
||||||
|
display_name="Color to RGB Int",
|
||||||
|
category="utils",
|
||||||
|
description="Convert a color to a RGB integer value.",
|
||||||
|
inputs=[
|
||||||
|
io.Color.Input("color"),
|
||||||
|
],
|
||||||
|
outputs=[
|
||||||
|
io.Int.Output(display_name="rgb_int"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def execute(
|
||||||
|
cls,
|
||||||
|
color: str,
|
||||||
|
) -> io.NodeOutput:
|
||||||
|
# expect format #RRGGBB
|
||||||
|
if len(color) != 7 or color[0] != "#":
|
||||||
|
raise ValueError("Color must be in format #RRGGBB")
|
||||||
|
r = int(color[1:3], 16)
|
||||||
|
g = int(color[3:5], 16)
|
||||||
|
b = int(color[5:7], 16)
|
||||||
|
return io.NodeOutput(r * 256 * 256 + g * 256 + b)
|
||||||
|
|
||||||
|
|
||||||
|
class ColorExtension(ComfyExtension):
|
||||||
|
@override
|
||||||
|
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||||
|
return [ColorToRGBInt]
|
||||||
|
|
||||||
|
|
||||||
|
async def comfy_entrypoint() -> ColorExtension:
|
||||||
|
return ColorExtension()
|
||||||
3
nodes.py
3
nodes.py
@ -2432,7 +2432,8 @@ async def init_builtin_extra_nodes():
|
|||||||
"nodes_wanmove.py",
|
"nodes_wanmove.py",
|
||||||
"nodes_image_compare.py",
|
"nodes_image_compare.py",
|
||||||
"nodes_zimage.py",
|
"nodes_zimage.py",
|
||||||
"nodes_lora_debug.py"
|
"nodes_lora_debug.py",
|
||||||
|
"nodes_color.py"
|
||||||
]
|
]
|
||||||
|
|
||||||
import_failed = []
|
import_failed = []
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user