• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

opacity on off expression

Community Beginner ,
May 15, 2021 May 15, 2021

Copy link to clipboard

Copied

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  ?

TOPICS
Expressions , How to

Views

7.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2021 May 15, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2021 May 15, 2021

Copy link to clipboard

Copied

This should work:

Math.floor(timeToFrames(time)/10)%2 ? 0 : 100

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 06, 2022 Feb 06, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2022 Feb 06, 2022

Copy link to clipboard

Copied

Probably. Depends on what you mean though. What are you randomizing? What are the constraints?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 06, 2022 Feb 06, 2022

Copy link to clipboard

Copied

I have a collection of the same logo repeated across the screen and the client wants the opacity to slowly pulse but wants it to occur randomly. I can get the pulse to work properly but I don't have a way to randomize the timing of when they fade and reappear.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2022 Feb 06, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 06, 2022 Feb 06, 2022

Copy link to clipboard

Copied

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)

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2022 Feb 06, 2022

Copy link to clipboard

Copied

Something like this maybe:

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

fadeFrames = 5; // should be less than minOn and minOff

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;
}
t2 = time - tPrev;
f = framesToTime(fadeFrames);
t2 < myOn ? linear(t2,0,f,0,100) : linear(t2,myOn,myOn+f,100,0)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 10, 2023 Oct 10, 2023

Copy link to clipboard

Copied

LATEST

Great code! Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines