Highlighted

Creating colour control that restricts options to a limited palette

New Here ,
Jun 18, 2020

Copy link to clipboard

Copied

Beginner to expressions, looking to create a motion graphics template for Premiere use that restricts the colour options to our brand colour palette - ie a half-dozen or so specific non-contiguous colour hex codes.

 

I'm assuming there should be a way to restrict the colour options (other than asking nicely), but can't work out the details. Any advice or suggestions would be a big help!

Topics

Expressions

Views

123

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Creating colour control that restricts options to a limited palette

New Here ,
Jun 18, 2020

Copy link to clipboard

Copied

Beginner to expressions, looking to create a motion graphics template for Premiere use that restricts the colour options to our brand colour palette - ie a half-dozen or so specific non-contiguous colour hex codes.

 

I'm assuming there should be a way to restrict the colour options (other than asking nicely), but can't work out the details. Any advice or suggestions would be a big help!

Topics

Expressions

Views

124

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jun 19, 2020

Copy link to clipboard

Copied

There isn't such a thing per se, but of course nothing stops you from defining a custom array of hex values, tie them to a dropdown or slider index and use them in your internal code.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jun 19, 2020

Copy link to clipboard

Copied

Thanks Mylenium! Appreciate the steer in the right direction.

 

Now nothing stops me (other than having no clue how to define a custom array) 😉

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jun 19, 2020

Copy link to clipboard

Copied

Update:

 

I borrowed some ELSE IF code from https://community.adobe.com/t5/after-effects/slider-control-for-shape-layer-fill-colour/td-p/9561773... and ended up with:

 

colourSlider = thisComp.layer("Expression controls").effect("Colour slider")("Slider").value;
if (colourSlider < 1)

[227,6,19,255]/255

else if (colourSlider < 2)

[254,232,0,255]/255

else if (colourSlider < 3)

[46,43,134,255]/255

else if (colourSlider < 4)

[146,192,40,255]/255

else if (colourSlider < 5)

[63,175,228,255]/255

else if (colourSlider <= 6)

[168,72,149,255]/255

 

Can't imagine this is the most elegant way of doing the job, but until I can figure out how to create an array of colour values, it does do the job...

 

Anyone wants to walk me through something neater, I'm not going to complain 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Guide ,
Jun 19, 2020

Copy link to clipboard

Copied

Arrays are very basic and you can easily help yourself with a short google search.

 

What Mylenium said would look like this:

 

color1 = [227,6,19,255];

color2 = [254,232,0,255];

color3 = [46,43,134,255];

mycolors = [color1, color2, color3];

index = thisComp.layer("Expression controls").effect("Colour slider")("Slider");

choosenColor = (mycolors[index])/255;

 

*Martin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jun 19, 2020

Copy link to clipboard

Copied

Thanks for the help.I have been looking into arrays, but most of what I can find assumes a certain amount of code savvy I don't possess. Was under the impression arrays were numerical only, and couldn't work out how to convert rgba values (each colour being its own array?) into a single number that could then go into an array of colours. Think I was probably on the wrong track. 

 

Unfortunately, looks like AE doesn't like your suggestion - 'couldn't turn result into numeric value' error on the first line. Unless I'm missing something? I'm probably missing something...

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Guide ,
Jun 19, 2020

Copy link to clipboard

Copied

You can pack arrays into an array. This is endless.

 

Are you on the newest version? I've read that there are issues with expressions.

I did test the code on my side and it worked. It's pretty basic, tough.

 

*Martin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jun 19, 2020

Copy link to clipboard

Copied

Nope; I'm on 16.1.3, for now.

 

To double-check, this is to go in the expression for the colour fill (rather than in the slider)? 

 

Is there a line missing? Again, I don't really know what I'm doing, but to me it looks like the choosenColor variable isn't used anywhere, and there's no output (which I think is what's causing the error).

 

Not sure what I'm doing wrong if not!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Guide ,
Jun 19, 2020

Copy link to clipboard

Copied

I've put the code on a text layer to see, if and how the array is returned. I'm not sure what a color fill needs as input. Yes, the code has to go into the color fill property.

 

You are right about the last line of my code. You don't necassary need to assign the operation to a variable, but to me, this looks cleaner. The result of the last line is automatically the output. But you can try to call choosenColor; beneath the last line just to be sure. Maybe color fill wants a clear value instead a short calculation.

 

I always use text laysers to debug issues like that. That's the easiest way in AE so acutall see with what values you are dealing.

 

*Martin

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
AFIFS LATEST
New Here ,
Jun 22, 2020

Copy link to clipboard

Copied

Thanks for the tip about using a text layer to monitor output, that's really handy!

 

Worked out how to get the output working for colour; it needs the rgba output as a four item array, so I amended the last line to:


chosenColour = [mycolours[index][0]/255,mycolours[index][1]/255,mycolours[index][2]/255,mycolours[index][3]/255];

 

Which seems to work! As long as the slider is set to an integer... For all the intervening decimals, it resets to the default colour. 😞

 

Need to work out how to get it to default to the closest integer, or some other workaround. Any ideas?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...