Animatron/player — pull request #66 by shamansir (2013-01-08 00:32:50+00:00)
Title: Revert time logic back for modifiers and tweens

:star2: :star: :guardsman: :star: :star2:

The Coolest Pull Request, codename `The Savior`!

This pull request reverts some really bad new (and, they were also a _brand_ new ones) changes, but keeps a good parts of them.

Some period before the time-restricted modifiers (and tweens with bands, due to the same origin of them) were called all the way during the elements band, receiving `0` before their own band was started and `1` when it was already finished. Also, the tweens were trying to be smart and tried to sum or even multiply their effect in the context of the same tweens types. The good old times come back, no more oversmart behavior, now everything is much simpler (again)!

First of all: We reverted back to overriding the effects of tweens with the same type. So if your tweens with the same type overlap in time, only the last-added tween will give the effect during overlapping period.

Second of all: No more calling tweens or modifiers before or after their own bands. If you specify the band, tween or modifier acts only in the range of the specified band (if not overlapped with another tween as mentioned in previos paragraph) again.

Third of all: All good changes stay:

* `b().modify(function(t, duration) { ... })` — will call the modifier through all the element's band and gets this band duration as a `duration` argument; this modifier gets local time in range of `[0..1]`, relatively to the element's own band (it is not guaranteed to get exact 0 or 1 everytime, because rendering calls may skip these frames due to low FPS, use the last type to ensure to call modifier at the start or at the end of a band); second argument for this function is the duration of element's band, so you may calculate the actual local time in any moment; `t` is in the range `[0..1]`, the same way as for all modifier types below;
* `b().modify([x, y], function(t, duration) { ... })` — restict modifier with its own band, `t` will be relative to this band and `duration` will be a duration of this band; so, in case when modifier is defined like this: `b().band([2, 9]).modify([1, 3], some_func);`, `some_func` will be called at a global period of `[2+1..2+3] = [3..5]` and will always receive a `duration` of `3-1 = 2`;
* `b().modify(z, function(t, duration) { ... })` — guarantees to call a modifier at the time `z` of element's band (of course, if it fits the band), `duration` will be the element's band duration and `t` will be the actual time when modifier was called, relatively to this band; in case when modifier is defined like this: `b().band([2, 9]).modify(3.5, some_func);`, `some_func` will be called somewhere very near to a global time of `2+3.5 = 5.5` and will always receive a `duration` of `9-2 = 7`;

By the way, the last example has the alias `b().at(t, function() {...})`.

**NB:** In near future there also will be an additional useful method to restrict modifiers to time, also defined relative to their parent's band, with the help of `rmodify` method: so `b().modify(function() { ... })` will always be equal to `b().rmodify([0, 1], function() { ... })` and `b().rmodify(1, function() { ... })` will always call modifier at the end of element's band.

**NB:** Please do not forget that a second argument for every modifier or tween is a `duration` now.

:squirrel:

:waxing_gibbous_moon: :full_moon_with_face:

_Best regards, your U.W._