Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Logo black or white depending on background brightness

  • Logo black or white depending on background brightness

    Posted by Mårten Gunge on April 19, 2016 at 1:54 pm

    Hi.

    I want an expression to make a logo become black or white depending on the background brightness (dark=white logo, bright=black logo).

    I guess that one could use “sample image” in some sort of a way. Please enlighten me.

    Mårten Gunge replied 10 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 19, 2016 at 9:12 pm

    One way would be to have a light logo with an opacity expression like this:

    bg = thisComp.layer(“background”);
    rgb = bg.sampleImage([bg.width,bg.height]/2,[bg.width,bg.height]/2);
    hsl = rgbToHsl(rgb);
    if (hsl[2] > .5) 0 else 100

    and an expression like this on the dark logo:

    bg = thisComp.layer(“background”);
    rgb = bg.sampleImage([bg.width,bg.height]/2,[bg.width,bg.height]/2);
    hsl = rgbToHsl(rgb);
    if (hsl[2] > .5) 100 else 0

    Or you could use a similar concept to control the fill color of a single logo like this:

    bg = thisComp.layer(“background”);
    rgb = bg.sampleImage([bg.width,bg.height]/2,[bg.width,bg.height]/2);
    hsl = rgbToHsl(rgb);
    if (hsl[2] > .5) [0,0,0,1] else [1,1,1,1]

    Dan

  • Mårten Gunge

    April 20, 2016 at 9:50 am

    That did the trick. Thanks a lot.

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