ComfyUI
ComfyUI copied to clipboard
[Feature Request] Simple color selector.
Description
It would be convenient if it was possible to choose a color in the node for RGB and RGBA. I'll try to describe how I see it.
For INPUT_TYPES, 2 types should be added.
Each type should be displayed as a small rectangular area colored in the selected color located opposite the parameter name in the node.
When you click on this rectangle, a window with 3 or 4 parameters should appears.
Parameters for RGB:
Red: 0 - 255
Green: 0 - 255
Blue: 0 - 255
Parameters for RGBA:
Red: 0 - 255
Green: 0 - 255
Blue: 0 - 255
Alpha: 0.0 - 1.0
These parameters should come to the node function as a tensor (RGB: [1, 3] and RGBA: [1, 4]), red, green and blue should be divided by 255.0 (converted to 0.0 - 1.0).
Motivation
Yes, I know that nodes in ComfyUI do not require color as a parameter, but I beg you to think about those who develop plugins for ComfyUI.
Just look at what a node with two incoming RGBA parameters turns into.
It becomes difficult to perceive and frightening, but everything will be the opposite if these 8 parameters are replaced by 2.
I hope for your understanding. Thanks for reading it.
I do think as ComfyUI matures, this would be an important addition to add. Ideally, there should be a special datatype for color represented on the front end with a swatch that opens up a larger window with additional controls and an eyedropper like other programs out there.
In the meantime, until this is noticed, perhaps this can shorten the amount of datafields you have as a temporary improvement: https://gitlab.com/sofuego-comfy-nodes/comfy-qr/-/blob/c614f700823ba296640ed9f683fee42d9b23a35f/qr_nodes.py#L33-45 I ended up writing this function yesterday because I ran into the same problem, and chose do color via hex strings so that users can just copy and paste one thing instead of having to fill out 3 boxes.
@coreyryanhanson If you interested you can strip it from my nodes here: https://github.com/melMass/comfy_mtb/blob/84ac8ac852aeb962029bfd8369fe5ed59a203977/web/mtb_widgets.js#L317-L386
It could certainly be improved but it's already quite useful for my needs

That is extremely cool! I might just do that for now. If you don't mind me asking, what's the best place to see documentation for the javascript side of things when it comes to custom nodes? The Python I have a good handle on, but the javascript is something I'm totally unfamiliar with to be honest.
It suffered a lot, but now it's a little bit clearer to me. 😅 First you have the TS definitions in the web dir that are very useful! Then studying open source work from people that know better, pythongosss has a wide variety of tools that cover a lot of the ways things can be done: https://github.com/pythongosssss/ComfyUI-Custom-Scripts