Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random colours from exact colour control colours

  • Random colours from exact colour control colours

    Posted by Obed Ampong on July 26, 2023 at 1:41 am

    Hi,

    Please, I have this expression about random colours but I don’t want it to pick in-between colour. I want to choose just either colour 1, colour 2 or colour 3.

    Is there any way out?

    Regards

    Obed

    var color1 = effect(“Color Control”)(“Color”);

    var color2 = effect(“Color Control 6”)(“Color”);

    var color3 = effect(“Color Control 4”)(“Color”)

    random (color1, color2, color3);

    Obed Ampong replied 1 year, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    July 26, 2023 at 2:50 am

    Maybe like this:

    var color1 = effect("Color Control")("Color");
    var color2 = effect("Color Control 6")("Color");
    var color3 = effect("Color Control 4")("Color")
    var colors = [color1,color2,color3];
    var idx = Math.floor(random(colors.length));
    colors[idx];

    or like this if you want each color to hold longer than 1 frame:

    var color1 = effect("Color Control")("Color");
    var color2 = effect("Color Control 6")("Color");
    var color3 = effect("Color Control 4")("Color")
    var colors = [color1,color2,color3];
    var nFrames = 5;
    var f = timeToFrames(time);
    seed = Math.floor(f/nFrames);
    seedRandom(seed,true);
    var idx = Math.floor(random(colors.length));
    colors[idx];
  • Obed Ampong

    July 26, 2023 at 3:26 am

    Thank you very much, Dan

    Regards Obed

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