ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Randomly set a value among a set of value

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Garcia Loic
Randomly set a value among a set of value
on Jul 4, 2018 at 9:18:01 am

Hello,

In advance, sorry for my english. I should have been more attentive in class.



I want to define a random value among a defined set.

For the dash stroke. If the plot is closed, all values ​​for the dash are not beautiful.
We often have a dash that is bigger than the others.
And if we use offset, it's even more visible.

I have several hundred identical circle. I would like to define a different Dash size for everyone, from a list.

I would test to know what value are correct, and I would refer them to a list.

For more difficulty. I would like to define a specific Gap size, depending on the size of the dash defined above.

Thank You for you help.


Return to posts index

Walter Soyka
Re: Randomly set a value among a set of value
on Jul 4, 2018 at 10:53:06 am

Add a Slider Control effect to your layer, Alt+click its Slider stopwatch icon, and paste the following expression:

// generate one random number for this layer for use elsewhere
// set the random number generator to remains constant over time, using the layer index as the seed
seedRandom(index, true);
random();


Alt+click the Dash property stopwatch, and paste this expression:
// define lists of acceptable dashes and gaps.
// these will work in pairs -- the first gap value will always go with the first dash value, likewise with the second, etc.
dashes = [100, 150, 200, 250, 300];
gaps = [25, 20, 15, 10, 5];

dashes[Math.round(effect("random")("Slider") * (dashes.length-1))];


Alt+click the Gap property stopwatch, and paste this very similar expression:
// define lists of acceptable dashes and gaps.
// these will work in pairs -- the first gap value will always go with the first dash value, likewise with the second, etc.
dashes = [100, 150, 200, 250, 300];
gaps = [25, 20, 15, 10, 5];

gaps[Math.round(effect("random")("Slider") * (gaps.length-1))];


Of course, you can modify the numbers in the lists to suit the aesthetics of your project, or extend or shorten the lists, but this will allow each layer to pull a separate dash/gap pair from your list of approved values.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Garcia Loic
Re: Randomly set a value among a set of value
on Jul 4, 2018 at 11:10:02 am

Thank you for your help,
I will test it here :B


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]