mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-11 00:47:14 +08:00
fix: Bug when setting transparency in color picker (#14764)
Some checks are pending
Detect Unreviewed Merge / detect (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (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
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
Some checks are pending
Detect Unreviewed Merge / detect (push) Waiting to run
Python Linting / Run Ruff (push) Waiting to run
Python Linting / Run Pylint (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Waiting to run
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (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
Execution Tests / test (macos-latest) (push) Waiting to run
Execution Tests / test (ubuntu-latest) (push) Waiting to run
Execution Tests / test (windows-latest) (push) Waiting to run
Test server launches without errors / test (push) Waiting to run
Unit Tests / test (macos-latest) (push) Waiting to run
Unit Tests / test (ubuntu-latest) (push) Waiting to run
Unit Tests / test (windows-2022) (push) Waiting to run
This commit is contained in:
parent
b7ba504e06
commit
7f287b705e
@ -16,23 +16,30 @@ class ColorToRGBInt(io.ComfyNode):
|
|||||||
],
|
],
|
||||||
outputs=[
|
outputs=[
|
||||||
io.Int.Output(display_name="rgb_int"),
|
io.Int.Output(display_name="rgb_int"),
|
||||||
io.Color.Output(display_name="hex")
|
io.Color.Output(display_name="hex"),
|
||||||
|
io.Float.Output(display_name="alpha"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def execute(cls, color: str) -> io.NodeOutput:
|
def execute(cls, color: str) -> io.NodeOutput:
|
||||||
# expect format #RRGGBB
|
# expect format #RRGGBB or #RRGGBBAA
|
||||||
if len(color) != 7 or color[0] != "#":
|
if len(color) not in (7, 9) or color[0] != "#":
|
||||||
raise ValueError("Color must be in format #RRGGBB")
|
raise ValueError("Color must be in format #RRGGBB or #RRGGBBAA")
|
||||||
try:
|
try:
|
||||||
int(color[1:], 16)
|
int(color[1:], 16)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValueError("Color must be in format #RRGGBB") from None
|
raise ValueError("Color must be in format #RRGGBB or #RRGGBBAA") from None
|
||||||
|
|
||||||
|
alpha = 1.0
|
||||||
|
if len(color) == 9:
|
||||||
|
alpha = int(color[7:9], 16) / 255.0
|
||||||
|
color = color[:7]
|
||||||
|
|
||||||
r, g, b = hex_to_rgb(color)
|
r, g, b = hex_to_rgb(color)
|
||||||
|
|
||||||
rgb_int = r * 256 * 256 + g * 256 + b
|
rgb_int = r * 256 * 256 + g * 256 + b
|
||||||
return io.NodeOutput(rgb_int, color)
|
return io.NodeOutput(rgb_int, color, alpha)
|
||||||
|
|
||||||
|
|
||||||
class ColorExtension(ComfyExtension):
|
class ColorExtension(ComfyExtension):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user