mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-28 02:39:26 +08:00
Merge color primitive into existing color picker node
This commit is contained in:
parent
2d0bf97956
commit
2ff7f60542
@ -7,29 +7,29 @@ class ColorToRGBInt(io.ComfyNode):
|
|||||||
def define_schema(cls) -> io.Schema:
|
def define_schema(cls) -> io.Schema:
|
||||||
return io.Schema(
|
return io.Schema(
|
||||||
node_id="ColorToRGBInt",
|
node_id="ColorToRGBInt",
|
||||||
display_name="Color to RGB Int",
|
display_name="Color Picker",
|
||||||
category="utilities",
|
category="utilities",
|
||||||
description="Convert a color to a RGB integer value.",
|
description="Return a color RGB integer value and hexadecimal representation.",
|
||||||
inputs=[
|
inputs=[
|
||||||
io.Color.Input("color"),
|
io.Color.Input("color"),
|
||||||
],
|
],
|
||||||
outputs=[
|
outputs=[
|
||||||
io.Int.Output(display_name="rgb_int"),
|
io.Int.Output(display_name="rgb_int"),
|
||||||
|
io.Color.Output(display_name="hex")
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def execute(
|
def execute(cls, color: str) -> io.NodeOutput:
|
||||||
cls,
|
|
||||||
color: str,
|
|
||||||
) -> io.NodeOutput:
|
|
||||||
# expect format #RRGGBB
|
# expect format #RRGGBB
|
||||||
if len(color) != 7 or color[0] != "#":
|
if len(color) != 7 or color[0] != "#":
|
||||||
raise ValueError("Color must be in format #RRGGBB")
|
raise ValueError("Color must be in format #RRGGBB")
|
||||||
r = int(color[1:3], 16)
|
r = int(color[1:3], 16)
|
||||||
g = int(color[3:5], 16)
|
g = int(color[3:5], 16)
|
||||||
b = int(color[5:7], 16)
|
b = int(color[5:7], 16)
|
||||||
return io.NodeOutput(r * 256 * 256 + g * 256 + b)
|
|
||||||
|
rgb_int = r * 256 * 256 + g * 256 + b
|
||||||
|
return io.NodeOutput(rgb_int, color)
|
||||||
|
|
||||||
|
|
||||||
class ColorExtension(ComfyExtension):
|
class ColorExtension(ComfyExtension):
|
||||||
|
|||||||
@ -97,24 +97,6 @@ class Boolean(io.ComfyNode):
|
|||||||
return io.NodeOutput(value)
|
return io.NodeOutput(value)
|
||||||
|
|
||||||
|
|
||||||
class Color(io.ComfyNode):
|
|
||||||
@classmethod
|
|
||||||
def define_schema(cls):
|
|
||||||
return io.Schema(
|
|
||||||
node_id="PrimitiveColor",
|
|
||||||
display_name="Color",
|
|
||||||
category="utilities/primitive",
|
|
||||||
inputs=[
|
|
||||||
io.Color.Input("value", default="#ffffff"),
|
|
||||||
],
|
|
||||||
outputs=[io.Color.Output()],
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def execute(cls, value: str) -> io.NodeOutput:
|
|
||||||
return io.NodeOutput(value)
|
|
||||||
|
|
||||||
|
|
||||||
class PrimitivesExtension(ComfyExtension):
|
class PrimitivesExtension(ComfyExtension):
|
||||||
@override
|
@override
|
||||||
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||||
@ -124,7 +106,6 @@ class PrimitivesExtension(ComfyExtension):
|
|||||||
Int,
|
Int,
|
||||||
Float,
|
Float,
|
||||||
Boolean,
|
Boolean,
|
||||||
Color,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
async def comfy_entrypoint() -> PrimitivesExtension:
|
async def comfy_entrypoint() -> PrimitivesExtension:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user