Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions color sample size/possition

  • color sample size/possition

    Posted by Vojtěch Palme on January 10, 2017 at 7:15 pm

    Greetings, I want to make an interactive background consisting of a grid of square, animated PreComps animating away as something passes over them.
    To do that I’ve decided to make a matte and measure lightness under each of the squares and with the value it gives me remap its time.

    My comp is divided to 9×5 squers 220x220px each.
    To measure their lightness I use 45 slider controllers with this expression:
    sampleSize = [220,220];
    target = thisComp.layer("matte");
    samplePos = [0,0];
    rgb = target.sampleImage(samplePos, sampleSize, true, time);
    hsl = rgbToHsl(rgb);
    hsl[2]*100

    sampleSize = [220,220];
    target = thisComp.layer("matte");
    samplePos = [220,0];
    rgb = target.sampleImage(samplePos, sampleSize, true, time);
    hsl = rgbToHsl(rgb);
    hsl[2]*100

    etc.. moving the samplePos always by value of 220.
    Then I link each of the square’s time remap value to corresponding slider.
    It kind of works except I’m getting some kind of overlap of the measured areas.
    (on the left is the result – all the cyrcles that are under the matte (on the right) should be gone, but they only animate half way)
    How should I properly define the grid? And is there an easier way to achive my goal?
    Thank you.

    Vojtěch Palme replied 9 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    January 10, 2017 at 8:41 pm

    It seems like it should be like this:

    sampleSize = [110,110];
    target = thisComp.layer(“matte”);
    samplePos = [110,110];

    sampleSize = [110,110];
    target = thisComp.layer(“matte”);
    samplePos = [330,110];

    etc.

    Dan

  • Vojtěch Palme

    January 11, 2017 at 12:42 pm

    Works like a charm. As always thank you oh grand expressions wizard Dan 🙂

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