FORUMS: list search recent posts

# Turn RGB swatch into RGB values?

FAQ   •   VIEW ALL
 Turn RGB swatch into RGB values? on Aug 31, 2013 at 4:39:48 pm

So I am doing a UI concept in which 3D planes move back and forth based on a colour value, sort of like a 3D colour graph.

I want to link the position of the planes to the R, G, and B values of a layer's fill colour, however RGB colour fills (such as in Effect>Generate>Fill) are only ever displayed as a swatch, not an RGB value. I have tried many effects, and all that provide a layer with a fill or change the colour in some way just have a swatch to determine colour, as opposed to separate values like you get in the colour picker, or in something like the HSL effect.

Is it possible to "split" the swatch into the different values like you can split dimensions in the position parameter? If not, is there some way of changing the colour of a layer through RGB parameters as opposed to choosing a swatch with the colour picker.

 Re: Turn RGB swatch into RGB values?on Sep 1, 2013 at 9:12:32 pm

[William Marler] "Is it possible to "split" the swatch into the different values like you can split dimensions in the position parameter? If not, is there some way of changing the colour of a layer through RGB parameters as opposed to choosing a swatch with the colour picker."

You can do this with an expression. Color is stored as a 4 component array (or vector), so if you applied this to any Color Swatch you could produce different colors using RGB values:

50% Gray:
```r = 0.5; g = 0.5; b = 0.5; a = 1.0; [r,g,b,a];```

100% Red:
```r = 1; g = 0; b = 0; a = 1.0; [r,g,b,a];```

Instead of manually entering the values into the expression you could aaply an Effect > Expression Controls > 3D Point Control and point the expression to those values for the RGB components (alpha will generally be 1.0):

```rgb = effect("3D Point Control")("3D Point"); a = 1.0; rgb + [0,0,0,a];```

Note that internally all RGB values are in float (0.0 = black, 1.0 = white). If you wanted to supply 8 bit code values then you'd need to divide them by 255 to get the correct float value:

```rgb = effect("3D Point Control")("3D Point") / 255; a = 1.0; rgb + [0,0,0,a];```

Darby Edelen

 Re: Turn RGB swatch into RGB values?on Sep 6, 2013 at 6:06:21 pm

Thank You Darby! Much appreciated, it's always satisfying to link effects to sliders. :)