0

I'm trying to create an Essential Graphic that allows the user to change a layer's colour into 4 specific ones:

Teal: 7, 250, 198
Pink: 252, 12, 119
Black: 0, 0, 0
White: 255, 255, 255

  • Colour Control isn't an option as it gives too much freedom.
  • Checkbox Control isn't either as it is not a 2 colours boolean/switch.

A Slider Control I think would be a good option but I need something similar to the clamp expression to keep the slider in control, something that would make my slider move in ones or specific steps.

Maybe I'm completely off track, I'm open to better solutions!

1

Use a dropdown. Select Dropdown Expression Control from Effects>Expression Controls and hit edit to input the colour names.

enter image description here

Then use a switch to deal with the four possible choices.

let colourChoice = Math.round(thisComp.layer("White Solid 1").effect("Dropdown Menu Control")("Menu"));
switch (colourChoice){
    case 1 : [7, 250, 198, 255]/255.0;
        break;
    case 2 : [252, 12, 119, 255]/255.0;
        break;
    case 3 : [0, 0, 0, 0];
        break;
    default:  [1, 1, 1, 1];

}

N.B.:

  • Math.round on the firstline is to convert the numeric result returned from the dropdown to an integer, I'm not sure what kind of numerical value is returned from a dropdown, but just using let colourChoice = thisComp.layer("White Solid 1").effect("Dropdown Menu Control")("Menu") doesn't work.

  • Colours in expressions are four-dimensional RGBA arrays, because even if they don't use alpha they need a value for alpha.

  • And finally the / 255 after the array is to convert the 0-255 RGBA values into 0-1.0 floating point values for colour. You could do the maths beforehand, but it's more legible like this.

3
  • I've been using AE 2019 but I see now the great advantage of 2020. I've tried it but whatever I do it keeps saying Error: Expected: ; – Apeiron_Sound Jan 26 at 13:48
  • 2019 uses a different expression language. Instead of switch you'll have to use if(colourChoice === 1){…} else if (colourChoice === 2){… And use var instead of let – stib Jan 26 at 23:23
  • 2019 doesn't support Dropdown Menu, so I've tried on 2020 but that's where it shows that ; problem. – Apeiron_Sound Jan 27 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.