Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Randomize color

  • Dan Ebberts

    October 28, 2007 at 1:39 am

    This should work:

    seedRandom(index,true);
    random([1,1,1,1])

    Dan

  • Jason Jantzen

    December 10, 2012 at 9:13 pm

    This is great, Dan. Is there a way to keep the random seed range within a color hue?

    Jason Jantzen
    vimeo.com/jasonj

  • Dan Ebberts

    December 10, 2012 at 9:27 pm

    You can limit the range by passing two arrays to random. For example, this will give you different variations of red:

    seedRandom(index,true);
    random([.25,0,0,1],[1,0,0,1])

    Dan

  • Jason Jantzen

    December 10, 2012 at 9:38 pm

    ok, this is pretty awesome 🙂 I’m trying to understand the color system though. Are those 32 bit values?

    Jason Jantzen
    vimeo.com/jasonj

  • Dan Ebberts

    December 10, 2012 at 10:39 pm

    They’re floating point, with individual channel values between 0.0 and 1.0.

    Dan

  • Daniel Sánchez de miguel

    January 13, 2015 at 5:41 pm

    would there be a way to call for say, four specific colors? then have it so, each time you duplicate the solid it creates another one with one of the 4 defined colors?

    Also, to define such colors in floating point mode… would I have to divide RGBA values by 255 in order to get the floating point color values?

    Thanks,
    Dani

  • Dan Ebberts

    January 13, 2015 at 6:07 pm

    This should give you the idea:

    color0 = [255,0,0,255]/255; // red
    color1 = [0,255,0,255]/255; // green
    color2 = [0,0,255,255]/255; // blue
    color3 = [255,255,0,255]/255; // yellow

    colors = [color0,color1,color2,color3];
    seedRandom(index,true);
    colors[Math.floor(random(colors.length))];

    Dan

  • Daniel Sánchez de miguel

    January 13, 2015 at 6:15 pm

    Thank you Dan,

    That worked beautifully.

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