Skip to main content
gdg59535
Participant
May 15, 2021
Question

opacity on off expression

  • May 15, 2021
  • 2 replies
  • 13052 views

sorry, i am a beginner  ...

 

i wanted to know if  i can make the opacity of a layer going on and off  (say 10 frames on and 10 frames off) with an expression  ?

This topic has been closed for replies.

2 replies

Dan Ebberts
Community Expert
Community Expert
May 15, 2021

This should work:

Math.floor(timeToFrames(time)/10)%2 ? 0 : 100
Participant
February 6, 2022

Is there a way to randomize this across a long timeline instead of constant pulsing?

Participant
February 6, 2022

That's still pretty vague. This might be one way:

// min/max on & off times in frames
minOn = 5;
maxOn = 40;
minOff = 5;
maxOff = 40;

t = tPrev = 0;
seg = 1;
while (t <= time){
  seedRandom(seg,true);
  myOn = framesToTime(random(minOn,maxOn));
  myOff = framesToTime(random(minOff,maxOff));
  tPrev = t;
  t += myOn + myOff;
}
time - tPrev < myOn ? 100 : 0

Thank you, Dan. This is almost exactly what I was looking for. Is there a way to smooth the transition by the amount of frames? Similar to the fade duration included in this expression.

 

fadeDuration = thisComp.frameDuration*48;
maxDelay = .5;
seedRandom(index,true);
delay = random(maxDelay);
t = time -(inPoint + delay);
linear(t,0,fadeDuration,0,100)

 

 

Mylenium
Legend
May 15, 2021

Sure. Could be as simple as

 

Math.floor(time%10)*100;

 

which creates an alternating on/off animation every ten frames when applied to the opacity.

 

Mylenium