Forum Replies Created

Page 143 of 1081
  • Something like this should work:

    s = thisComp.layer(“layer with slider”).effect(“Slider Control”)(“Slider”);
    linear(s,0,5.2,0,100)

    Dan

  • Dan Ebberts

    May 19, 2020 at 5:55 pm in reply to: Can’t reference self position with valueAtTime

    When an expression references the value of the property hosting the expression, it always get the pre-expression value. Expressions have no memory, so an expression can’t access its own results from previous frames. There are usually ways to work around that limitation though, depending on what you’re trying to do.

    Dan

  • Dan Ebberts

    May 15, 2020 at 5:39 pm in reply to: If statement for Colour

    I guess you could create your own conversion function:


    function hexToRgb(theHex){
    var r = parseInt(theHex.substr(0,2),16);
    var g = parseInt(theHex.substr(2,2),16);
    var b = parseInt(theHex.substr(4,2),16);
    return [r/255,g/255,b/255,1];
    }
    c1 = "292B2B";
    c2 = "FFFFFF";
    v = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Fill 1").color;
    c = ((Math.round(v[0]*255)*256 + Math.round(v[1]*255))*256 + Math.round(v[2]*255)).toString(16);
    if (c == c1.toLowerCase())
    hexToRgb(c2)
    else if (c == c2.toLowerCase())
    hexToRgb(c1)
    else
    value

    Dan

  • Dan Ebberts

    May 15, 2020 at 5:20 pm in reply to: If statement for Colour

    What version of After Effects are you using? I don’t remember when hexToRgb() came in, but I think it’s fairly recent.

    Dan

  • Dan Ebberts

    May 15, 2020 at 4:42 pm in reply to: If statement for Colour

    The v variable is the shape’s rgba color array where each color channel is a value between 0 and 1. In the c variable calculation, each color channel value is converted to an integer value between 0 and 255 (by multiplying by 255 and rounding) the red channel is essentially moved 16 bits to the left (by multiplying by 256 twice), the green channel moved 8 bits to the left and the blue channel is left in the right-most 8 bits, then the whole thing is converted to hex so it can be compared to your hex values.

    Specifying your colors as rgba arrays would completely change the calculation because you would then be comparing arrays of floating point values rather than hex integers so you might run into issues where the values don’t quite match exactly, so you might have check for values being within a certain range of each other (like .001 or .0001).

    Dan

  • Dan Ebberts

    May 15, 2020 at 3:17 pm in reply to: If statement for Colour

    Ah. That would be more like this:


    c1 = "292B2B";
    c2 = "FFFFFF";
    v = thisComp.layer("Shape Layer 1").content("Rectangle 1").content("Fill 1").color;
    c = ((Math.round(v[0]*255)*256 + Math.round(v[1]*255))*256 + Math.round(v[2]*255)).toString(16);
    if (c == c1.toLowerCase())
    hexToRgb(c2)
    else if (c == c2.toLowerCase())
    hexToRgb(c1)
    else
    value

    Dan

  • Dan Ebberts

    May 14, 2020 at 6:05 pm in reply to: If statement for Colour

    Like this maybe:


    c1 = "292B2B";
    c2 = "FFFFFF";
    v = value;
    c = ((Math.round(v[0]*255)*256 + Math.round(v[1]*255))*256 + Math.round(v[2]*255)).toString(16);
    if (c == c1.toLowerCase())
    hexToRgb(c2)
    else if (c == c2.toLowerCase())
    hexToRgb(c1)
    else
    value

    Dan

  • Try it this way:


    n = thisLayer("Effects").numProperties;
    accum = [0,0];
    for (i = 1; i <= n; i++){
    if (thisLayer("Effects")(i).name.indexOf("PSR Offset") > -1){
    accum += thisLayer("Effects")(i)("Position");
    }
    }
    value + accum

    Dan

  • It depends on how you have things set up, but I guess I’d add a dropdown menu control to a layer named “Controls”, add 3 additional elements to the control and name them to match your previous expression:

    INSTAGRAM
    TWITTER
    FACEBOOK
    YOUTUBE
    SKYPE
    SNAPCHAT

    Then add an expression like this to each of your logo layers (this example would be for the FACEBOOK layer (#3 in the list):

    id = thisComp.layer(“Controls”).effect(“Dropdown Menu Control”)(“Menu”).value;
    x = id == 3 ? 630.5 : 572.5; // this is where you specify the id that corresponds to this layer
    [x,value[1]]

    Something like that…

    Dan

  • In my experience, attempting to simulate radio button behavior with checkboxes is doomed to failure. It may seem like it works, but there are subtle order-of-operation dependencies that will make it unreliable. Can’t you use a dropdown menu instead?

    Dan

Page 143 of 1081

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy