-
Prevent subsequent random value
Hi! I have a precomp of 5 shapes with 4 different variants. Each variant runs for 6 frames, and they’re next to each other in the timeline. So shape 1 runs from 0-1sec, shape 2 runs from 1-2 sec, etc.
I’m trying to randomize the timeremap of this precomp, to try to get different patterns (without repeating shapes.So for example: random remaps time to 1, the shape on the next frame can be 2,3,4,5
then, if 2 was generated, the next one can be 1,3,4,5, etc.Each shape should be visible for 2 frames, which is why I’m using posterizeTime.
I’ve been trying a few approaches, but nothing really works, so I’m hoping you can help me!
posterizeTime(12);
const min = 0;
const max = 120;
const offset = 24;
let currentValue = timeToFrames(timeRemap);
let newValue = Math.round(random(min, max));
while (newValue <= currentValue + offset && newValue >= currentValue – offset) {
newValue = Math.round(random(min,max));
}
framesToTime(newValue)and also like this
const min = 0;
const max = 4;
posterizeTime(12);
const currentShape = time;
const previousShape = time – 1/12;
while (Math.floor(currentShape) === Math.floor(previousShape)) {
seedRandom(random());
random(min, max);
}