ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Dynamic percentage change.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
John Cuevas
Dynamic percentage change.
on Sep 17, 2018 at 12:45:11 pm

I have a 4 bars(1 bar with 4 colors), each represents a percentage of ingredients in a formula. Is there a way to adjust 1 ingredient and have the other 3 to proportionally expand or shrink based on that adjustment. For example, if all the ingredients were 25% and I adjusted 1 to 28% have the others adjust to 24%. Every time I try to create an expression to do this, I run into a circle that if I adjust A to 20% , then adjust B to 50% how do I get A to then re-adjust?

Johnny Cuevas, Editor
ThinkCK

"I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
---THOMAS EDISON on inventing the light bulb.


Return to posts index

Dan Ebberts
Re: Dynamic percentage change.
on Sep 17, 2018 at 3:39:57 pm

I'm not sure how you have things set up, but it seems like the percentage for A would be something like this:

100*A/(A+B+C+D)

and for B:

100*B/(A+B+C+D)

etc.

Dan



Return to posts index

John Cuevas
Re: Dynamic percentage change.
on Sep 17, 2018 at 4:20:24 pm

Hi Dan,

Right now I have 4 sliders for inputs, the outputs are to control the scale of 4 different colored bars(using some scripting you helped someone else with). In the project attached, my 4 inputs are B1 = 25, B2 = 25, B3 = 10, B4 = 50, for 100%, but the outputs are 24.09, 23.82, 8.48, 45.45. Trying to set this up to demonstrate/illustrate the ease and quickness of beverage formula changes but it's been anything but easy and quick.

Really appreciate you taking the time to look at this.

12723_percentage.aep.zip

Johnny Cuevas, Editor
ThinkCK

"I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
---THOMAS EDISON on inventing the light bulb.


Return to posts index


Dan Ebberts
Re: Dynamic percentage change.
on Sep 17, 2018 at 4:30:27 pm

So for bar 1, it would look like this:

x = scale[0];
b1 = thisComp.layer("Controls").effect("bar 1")("Slider");
b2 = thisComp.layer("Controls").effect("bar 2")("Slider");
b3 = thisComp.layer("Controls").effect("bar 3")("Slider");
b4 = thisComp.layer("Controls").effect("bar 4")("Slider");
y = 100*b1/(b1+b2+b3+b4);
[x,y]


Dan



Return to posts index

Kalleheikki Kannisto
Re: Dynamic percentage change.
on Sep 17, 2018 at 4:39:14 pm
Last Edited By Kalleheikki Kannisto on Sep 17, 2018 at 4:47:03 pm

You do realize that once you've adjusted even just one slider, the slider input values lose their meaning. So you may want to add text fields that give you the final output values for the sliders with the same logic. Unless you're applying there to the sliders themselves. Even there some rounding would be a good idea.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

John Cuevas
Re: Dynamic percentage change.
on Sep 17, 2018 at 4:50:44 pm

I realize that now. That was probably 90% of my problem on Friday, not seeing that issue. I was thinking that their might be a way to make it so that the new input on the slider would adjust the other sliders and itself remain be fixed, until I adjusted another slider. IE...go from 25 to 28, BCD change to 24. Change B to 21 A to 28, CD to 25.

I'll link the text to the slider output, and I should be good to go.

Thank You too, Kalleheikki.

Johnny Cuevas, Editor
ThinkCK

"I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
---THOMAS EDISON on inventing the light bulb.


Return to posts index


John Cuevas
Re: Dynamic percentage change.
on Sep 17, 2018 at 4:44:27 pm

Thank you very much. I started out with a formula like that on Friday, it wasn't working correctly and as I went I made it more and more complicated, which did not help the process at all.

You are the best.

Johnny Cuevas, Editor
ThinkCK

"I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
---THOMAS EDISON on inventing the light bulb.


Return to posts index

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