PhotoDune

Expression help for Color Scheme ?

193 posts
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Bulgaria
  • Elite Author
  • Exclusive Author
  • Has been a member for 4-5 years
+3 more
AlexZlatev says

Hi :) I want to make color scheme expressions as the title of the thread says. I think its going to be helpful to all of us around if we solve this problem well here is what I ‘ve done and the problem:

My project is seperated into different scenes, each has 2 layers of optical Flares and Adjustment layer with tritone effect applied. I put HLS control to OF layers and linked to layer in the Main Comp to control this parameters for all of the comps from there I linked the tritone effect to the same effect into Main comp for easier control. So far so good BUT , now you can control everything manually but I want to make something like 4 presets. So I applied this to Hue of the HLS

y = thisComp.layer(“Adjustment Layer 6”).effect(“Color Scheme”)(“Slider”) if (y 1){ 78; if (y 2){ 255; } }else{ value; }

For someone who know something about expression that might look foolish from my side but here is my next step – I added another layer with checkbox control and applied to the slider control the following expression

x = thisComp.layer(“Color Scheme”).effect(“Color Scheme 01”)(“Checkbox”) if (x == 1){ 1; }else{ 5; }

So basically if you click the checkbbox of Color Scheme 1 you’ll have some parameters if you click on color scheme 2 you`ll have another one But How to solve the problem with the Tritone effect.

In conclusion I want to make 4 checkboxes and if you click on 1 the HLS and TRITONE have some parameters if you click on the second one they have different. If you click on Custom , then you can adjust the HLS and the rest by hand. I hope u understood what I mean. Im sure that there is a lot easier way to do that but im really really noob at expressions I can only link stuff so thats why im asking . I hope this thread to be usefull for more people, because its going to be easier to the users too :)

4446 posts
  • Elite Author
  • Community Moderator
  • Sold between 50 000 and 100 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips moderator says

Checkboxes are a bad idea, because you can have several checked simultaneously. You’re much better off having a slider which is limited to integer values. That’s how I do it. I use 0 for custom stuff.

Then on each color element I use a switch statement.

L = topComp.layer("controller").effect("color scheme").value;
switch(L) {
    case 0:
        value;
        break;
    case 1:
        //color ref 1
        break;
    case 2:
        //color ref 2 etc.
        break;
    default:
        value;
}

Always use ”.value” after a checkbox ref (and after all refs actually). Otherwise you can get problems with datatyping. You may find that

checkboxRef == true

doesn’t work, whereas
checkboxRef.value == true
will.

To limit the slider to integer values between 0 and 5:

a = Math.round(value);
linear(a, 0, 5, 0, 5);

You can avoid messing around with color values in the expressions by keyframing the colors, then pulling out the appropriate keyframe too.

193 posts
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Bulgaria
  • Elite Author
  • Exclusive Author
  • Has been a member for 4-5 years
+3 more
AlexZlatev says

hi felt , thanks for you respond, I dont understand where to paste this expression , from all I read i think this expression makes switchable 2 keyframes. I mean if u put 2 keyframes I can control from the slider control which one to be active ? if thats right on what effect to paste this expression ?

193 posts
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Bulgaria
  • Elite Author
  • Exclusive Author
  • Has been a member for 4-5 years
+3 more
AlexZlatev says

Thank you very very much Felt , here is how I solve the problem if anyone else is interested -

I created another Adjustment layer with Color Controls called Highlights 1, 2,3 Midtones 1,2,3 and Shadows 1,2,3 I placed different colors for each case – Case 1 Highlight 1 , Midtones 1, Shadows 1 after that I applied this expression –
 

L = thisComp.layer("Adjustment Layer 6").effect("Color Scheme")("Slider").value
switch(L) {
    case 0:
value;
break;
   case 1:
thisComp.layer("Adjustment Layer 7").effect("highlight 1")("Color")
 break;
   case 2:
thisComp.layer("Adjustment Layer 7").effect("highlight 2")("Color")
        break;
   case 3:
thisComp.layer("Adjustment Layer 7").effect("highlight 3")("Color")
        break;
    default:
        value;
}
Then This expression to the HUE
L = thisComp.layer("Adjustment Layer 6").effect("Color Scheme")("Slider").value
switch(L) {
    case 0:
value;
break;
   case 1:
52
 break;
   case 2:
123
        break;
   case 3:
302
        break;
    default:
        value;
}

And to slider Control the limiting expression between 0-3, so if you slide the from 0 to 3 you get different values from this effects Tritone and HLS , if you select 0 from the slider it leaves the control from the original layer with the effects applied so 0 is custom . Thank you once again Felt_tips you are the masters for expressions !

PS I tried it also with valueAtTime and it works fine but it causes issues with the custom preset

4446 posts
  • Elite Author
  • Community Moderator
  • Sold between 50 000 and 100 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips moderator says

Hi Alex,

Looks like you sorted it out. Switch doesn’t actually switch anything – it’s just the name of a kind of conditional statement in javascript. (you’ve probably clocked by now that javascript and expressions language look really rather similar!)

valueAtTime is really only something to use when you don’t want to use the time that After Effects automatically uses – i.e. the current time. For instance if you are working with a precomp structure where comps are offset in time, you would probably need to use valueAtTime to correct the offset.

Did you know that you can also adjust the Hue on a Tint effect for instance? There you just need to convert RGB to HSL and back.

For instance, on Tint / Map White to:

colRGB = value; //put the unmodified value into a variable
colHSL = rgbToHsl(colRGB); //convert to HSL
colHSL[0] = 0.2; //change the hue (values 0-1)
colRGB = hslToRgb(colHSL); //convert back

The keyword “value” always refers to the value before it’s modified by the expression, when an expression refers to itself. When another property is referenced though, it always refers to the value after being modified by the expression.

for instance:

thisProperty.value; // refers to the pre expression value

whereas…

layer("different layer").effect("Tint")(1).value; //refers to the post expression value
193 posts
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Bulgaria
  • Elite Author
  • Exclusive Author
  • Has been a member for 4-5 years
+3 more
AlexZlatev says

thank you for your detailed reply Felt. I didnt know about these things. As I said my knowledge in rexpression is really basic. Im glad that I achieved the desired effect with your help .

4446 posts
  • Elite Author
  • Community Moderator
  • Sold between 50 000 and 100 000 dollars
  • Author had a File in an Envato Bundle
  • Beta Tester
  • Has been a member for 4-5 years
  • United Kingdom
+5 more
felt_tips moderator says

thank you for your detailed reply Felt.
My pleasure.


As I said my knowledge in rexpression is really basic.

Just keep writing ‘em. Before long you’ll realize you’re an expressions pro.

Then you can come and post answers in the forums. :)

by
by
by
by
by