ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Color control expression - target own color picker in if statement

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jeroen Rommelaars
Color control expression - target own color picker in if statement
on Dec 4, 2017 at 8:58:24 am
Last Edited By Jeroen Rommelaars on Dec 4, 2017 at 9:40:41 am

EDIT: I'm silly - I had an expression on the textlayer that already changed the source text if the name of the layer was the default. Silly me.
Consider this fixed ;)

Hey guys,

Im currently linking all kinds of colors to a master layer with several color control effects added to it.
In the same comp as the master color control, I have several text layers that correspond with the color effects.
For example, i have a color effect thats called background color, and I also have a text layer called background color.

With expressions, I made it so that if you put a hexcode into the text layer, the color of the effect changes to that color. Works great.

What i am trying to achieve now, is that when the name of the text layer is its default name, in this case 'background color', the effect takes the color of the effects own color picker.

My code looks like this:

txt = comp("master").layer(8).text.sourceText;
if (txt=='background color'){
thisLayer.effect("background color")("Color")
} else {
c = parseInt(txt,16);
r = c >> 16;
g = (c & 0x00ff00) >> 8;
b = c & 0xff;
[r,g,b,255]/255}

The problem is, that when the text layer is its defaul name, it doesnt take the color of the color picker, but rather its original color when I added the effect - always bright red.

I need to adjust this part of the expression: thisLayer.effect("background color")("Color")
to something that points directly at the color picker, but I cant figure it out.

Anyone knows how to achieve that or can point me in the right direction?

Cheers!

txt = comp("master").layer(8).text.sourceText;
if (txt=='background color'){
thisLayer.effect("background color")("Color")
} else {
c = parseInt(txt,16);
r = c >> 16;
g = (c & 0x00ff00) >> 8;
b = c & 0xff;
[r,g,b,255]/255}


Return to posts index

Scott McGee
Re: Color control expression - target own color picker in if statement
on Dec 4, 2017 at 9:41:37 am

Not too sure what's wrong with yours.

But I've re written it to work for me.

txt = comp("master").layer(8).text.sourceText;
if(txt == ""){
effect("Fill")("Color")
} else {
txt = "0x" + thisComp.layer("Colour").text.sourceText;
r = txt >> 16;
g = (txt & 0x00ff00) >> 8;
b = txt & 0xff;
[r,g,b,255]/255
}


Altered for you

txt = thisComp.layer("Colour").text.sourceText;
if(txt == "background color"){
effect("background color")("Color")
} else {
txt = "0x" + thisComp.layer("Colour").text.sourceText;
r = txt >> 16;
g = (txt & 0x00ff00) >> 8;
b = txt & 0xff;
[r,g,b,255]/255
}


Return to posts index

Jeroen Rommelaars
Re: Color control expression - target own color picker in if statement
on Dec 4, 2017 at 11:10:22 am

Thanks mate,

See my EDIT at the top of the post.
I already had a sourcetext changing expression on the text layer which messed up my expression. A stupid mistake which i spent much too much time in fixing :P

Still thanks for the help, though!


Return to posts index


Scott McGee
Re: Color control expression - target own color picker in if statement
on Dec 4, 2017 at 11:17:58 am

Haha,

No i did not spot that.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]