Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 828

Community Tips & Tricks • Easing functions Simulator with ActionTimer plugin - Animations, Transitions

$
0
0
To explain, I want the number to start on 0 and end on 1 and then start on 1 and end on 0, but it should go: 0-1-0-1-0-1-0-1 and then 1-0-1-0-1-0-1-0 (using the easings of course), like mimicking an old light bulb.
In one single action (0-1-0-1-0-1-0-1-1-0-1-0-1-0-1-0) or in two separate actions (0-1-0-1-0-1-0-1 and 1-0-1-0-1-0-1-0)?

Anyway, here's the Lua code for the separate actions version, since they could be executed one after another in the Rainmeter code (one could get rid of the 1st function and just multiply with (x % 2) in the 2nd function, but to follow the script structure I put this in two functions):

Code:

local function easeOnOffBulb(x)return x % 2end-- ...function onoffBulb(x, s, e)return s + (e-s) * easeOnOffBulb(x)end
Take into account that x above is NOT the (counter / steps) value, but the counter value alone. This is because identifying whether the former value is the "even" or "odd" function execution is not possible, while the same is trivial for the latter value.

Also, take into account that, based on your description, you need to have an "odd" number of steps so that with the "start up" aka the 0-th step they make up an "even" number of function executions (e.g. 0-1-0 will start and end at the undesired same value, but 0-1-0-1 will start and end at desired different values).

By the way, as a bonus, this will also work for other non zero outputs, e.g. 0-7-0-7 or 7-0-7-0, for conveniency. Obviously, you control the start and end value via the s and e arguments, so onoffBulb(4, 0, 5) will give 0-5-0-5, while onoffBulb(4, 5, 0) will give 5-0-5-0.

Hopefully this will fully work as I described, since it's untested and written from my phone. ;-)

P.S. I think the 2nd function for one single action will have to take the steps value as its y parameter too, so something like:

Code:

function onoffBulb(x, y, s, e)return s + (e-s) * (x / y < 0.5 and easeOnOffBulb(x) or 1 - easeOnOffBulb(x))end
should do.

Statistics: Posted by Yincognito — less than a minute ago — Replies 2 — Views 7469



Viewing all articles
Browse latest Browse all 828

Trending Articles