It is currently March 29th, 2024, 2:06 pm

A formula that increases while a variable decreases.

Get help with creating, editing & fixing problems with skins
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

A formula that increases while a variable decreases.

Post by kyriakos876 »

Hello everyone,
I want to make an animation that shrinks, let's say, a box. But I want it to shrink slowly in the beginning and accelerate from there. Something like Accelerate easing, as google calls it. (Scroll down to where it says "Accelerate easing")
I've made something that goes like:

Code: Select all

[!SetVariable PP (Clamp(#PP#-(#PP#*0.2),24,336))]
But it does the opposite from that I want... I starts fast and slows down in the end. As you can already tell, it's a math problem... I want the term (#PP#*0.2) to increase as the #PP# decreases.
Obviously my solution wouldn't work as (#PP#*0.2) is linear y=a*x type, and I need it to be exponential e^(x) type but reversed...

This doesn't work either: (Clamp(#PP#-(1/(e**(#PP#))),24,336))]
NOTE: I don't want another action timer that creates another variable to replace that term that increases.

EDIT: In CSS this translates to

Code: Select all

cubic-bezier(0.4, 0.0, 1, 1);
in case that helps someone.

-Thanks in advance.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: A formula that increases while a variable decreases.

Post by kyriakos876 »

Reviving the thread in case anyone found a solution..
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: A formula that increases while a variable decreases.

Post by balala »

kyriakos876 wrote:Reviving the thread in case anyone found a solution..
I think I did, even two:
  1. The more elegant: [!SetVariable PP "(Round(Clamp((#PP#-(5000/#PP#)),24,336)))"]. Just note here that the 5000 used above is a kind of speed: the higher is the value you're using, the quicker the value of the variable will decrease. Probably you'll have to make a few tries, to get the best value, which match as better as possible your needs.
  2. The less elegant: [!SetVariable PP "(Round(Clamp(((#PP#>200)?(#PP#-10):(#PP#-20)),24,336)))"]. Besides being less elegant, this solution has one more possible disadvantage: the "speed change" occurs into one single step: with the above value while the value of the variable is greater then 200 ((#PP#>200)), at each step the variable is decreasing with 10 ((#PP#-10)), but below 200, it is decreasing with 20 ((#PP#-20)). Obviously you can easily change the limit where the variation speed changes and / or the values with which the variable decreases.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: A formula that increases while a variable decreases.

Post by kyriakos876 »

balala wrote:I think I did, even two:
  1. The more elegant: [!SetVariable PP "(Round(Clamp((#PP#-(5000/#PP#)),24,336)))"]. Just note here that the 5000 used above is a kind of speed: the higher is the value you're using, the quicker the value of the variable will decrease. Probably you'll have to make a few tries, to get the best value, which match as better as possible your needs.
  2. The less elegant: [!SetVariable PP "(Round(Clamp(((#PP#>200)?(#PP#-10):(#PP#-20)),24,336)))"]. Besides being less elegant, this solution has one more possible disadvantage: the "speed change" occurs into one single step: with the above value while the value of the variable is greater then 200 ((#PP#>200)), at each step the variable is decreasing with 10 ((#PP#-10)), but below 200, it is decreasing with 20 ((#PP#-20)). Obviously you can easily change the limit where the variation speed changes and / or the values with which the variable decreases.
The first one I came across with while trying random stuff out, but it doesn't work the way I want it to.. It's still linear and I want to grow exponentially as I mentioned above.
The second one is closer to what I want but still not very elegant as you said :D (I have to very carefully find the correct limits for 3 numbers. The 200 you have, the -10 and the -20 so it's pretty hard.)
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: A formula that increases while a variable decreases.

Post by balala »

kyriakos876 wrote:The first one I came across with while trying random stuff out, but it doesn't work the way I want it to.. It's still linear and I want to grow exponentially as I mentioned above.
For a non-linear variation try a this kind of formula: [!SetVariable PP "(Round(Clamp((#PP#-(2500000/#PP#**2)),24,336)))"].
kyriakos876 wrote:The second one is closer to what I want but still not very elegant as you said :D (I have to very carefully find the correct limits for 3 numbers. The 200 you have, the -10 and the -20 so it's pretty hard.)
One more addition: [!SetVariable PP "(Round(Clamp((((#PP#>300)||(#PP#<60))?(#PP#-10):(#PP#-20)),24,336)))"]. With this formula the smaller decrease is goin on at the beginning and the end of the interval, while in middle the greater decrease is applied.

Again in both cases you have to play around a bit to find the best numeric value(s) for your needs.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: A formula that increases while a variable decreases.

Post by kyriakos876 »

balala wrote:For a non-linear variation try a this kind of formula: [!SetVariable PP "(Round(Clamp((#PP#-(2500000/#PP#**2)),24,336)))"].
.
.
.
Yeeess this is good. I fiddled around a bit with 2500000 and found a sweet spot at 2000000.

Thanks for that one :17good
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: A formula that increases while a variable decreases.

Post by balala »

kyriakos876 wrote:Yeeess this is good. I fiddled around a bit with 2500000 and found a sweet spot at 2000000.
You're welcome. I'm glad if you got it working as you wanted.