Graphite icon indicating copy to clipboard operation
Graphite copied to clipboard

Create Color from Component Values

Open phailhaus opened this issue 6 months ago • 1 comments

A node that takes four numbers (int or float, doesn't matter) as R, G, B, and A and outputs a color is needed for situations where color is driven mathematically by other elements.

The best workaround I have found when alpha isn't needed is to create three gradients, one for Black->Red, Black->Green, and Black->Blue. I can then sample those gradients and use them to produce three duplicates of the geometry, each representing one color channel. Finally, I can blend them using the Lighten blendmode to get the composite image.

phailhaus avatar Jun 28 '25 00:06 phailhaus

My thoughts on this posted in Discord which can be used to adapt this into an implementation:

You could add it as like a Construct Color node which has modes for Grayscale, RGB, HSV, CMYK, Lab, etc. from a dropdown menu (you can reference other code examples) and it can take the different inputs for each of those parameters to produce a color as output.

Keavon avatar Jun 28 '25 01:06 Keavon