dhowe / ReadersJS

1 stars 4 forks source link

question about how fades work #115

Closed shadoof closed 7 years ago

shadoof commented 7 years ago

hi Daniel, I am trying to fine tune and remove artifacts from the VBs. I need to know:

dhowe commented 7 years ago

Yes, I mentioned this issue a while back. Currently it works according to, I believe, (2) above. The fade does not 'exist' at all until the delay time expires. So if another fade is running when that happens, it will be cancelled, even though it may have been initially called after the delayed fade.

shadoof commented 7 years ago

Right. And I'm sorry I missed this. (Hard to think through.) Can we switch to (1)? It will I think be the only way to handle more complex VBs. The existing problem now, I believe, is that 'peripheral' (haloing fades) may cancel the 'fade in' of even a current cell. Why? Peripheral fade-out code is properly delayed but then its actual, delay-expired fade may fire on the current word cancelling the current word's fade-in, whereas this fade-in was initiated more recently and should be the VB's top priority.

shadoof commented 7 years ago

And, to be clear, later fades (of any kind) should cancel any other fade including delayed fades that have not yet started to run and are in their 'delay state'.

dhowe commented 7 years ago

To clarify then, if we have 2 fades like this:

1. rt.fadeToColor(col1, 5);  // fade over 5 seconds
2. rt.fadeToColor(col2, 2, 6) // wait 5 seconds, then fade over 2 seconds

The first fade is immediately cancelled and nothing happens for 6 seconds, even though there would be no conflict here?

shadoof commented 7 years ago

I believe so, but I will devise a test, to be sure. (Not as easy as I thought because the old test rig is currently broken.)

shadoof commented 7 years ago

Actually oneword.html does work and demonstrate the problem (on my 'cayley' branch, which I've pushed). (test.html is broken.) But the case above is not the problem. This is:

  rt.colorTo({r:0,g:255,b:0,a:255}, 5, 5);
  rt.colorTo({r:255,g:0,b:0,a:255}, 10);

Desired behavior: second fade cancels the first fade and rt fades to (full-on) red over 10 secs. Actual behavior: rt fades (half-way) to red for 5 secs, then fades to green over 5.

Note that if the lines above were reversed:

  rt.colorTo({r:255,g:0,b:0,a:255}, 10);
  rt.colorTo({r:0,g:255,b:0,a:255}, 5, 5);

then both Desired and currently existing Actual behavior would be the same: rt fades (half-way) to red for 5 secs, then fades to green over 5 (the more recently invoked fade cancels an earlier invoked fade at the time that the more recently invoked fade starts its delayed operation).

shadoof commented 7 years ago

But, in the case of:

1. rt.fadeToColor(col1, 10);  // fade over 10 seconds
2. rt.fadeToColor(col2, 5, 5) // wait 5 seconds, then fade over 5 seconds

... the correct behavior (including as above) would need to be preserved. i.e. (2) would not cancel (1) immediately; it would cancel it after 5 seconds. (gets half way to col1 and the all the way to col2).

dhowe commented 7 years ago

I think I'm confused about the spec you are asking for. Does a subsequent call cancel previous calls immediately (1), or after their delay (2), or some mix of the two, perhaps depending on whether the prior fade has finished its delay period (3) ?

shadoof commented 7 years ago

Yeah. It's hard to think through.

colorTo(<col>, <fadeTime>) is equivalent to colorTo(<col>, <fadeTime>, 0)

... and so it should interrupts any fade on the the same rt, right away after 0. But if a delay is set, then it should only interrupt after the delay. The problem is simply that if a delayed fade does not (yet) exist, it can't be interrupted. Delayed fades should exist and should be interruptable from the moment their code is executed, even if they haven't started to do anything that is visible, as in the oneword case above.

dhowe commented 7 years ago

Ok, so we want the current behavior, except that previously invoked fades, which are still in their delay, should also be cancelled whenever a fade starts. Is that correct?

shadoof commented 7 years ago

Yes, that is correct (with the obvious qualification that a cancelation only happens when a more recently invoked fade starts its fade on the same rt object as a previously invoked fade).

shadoof commented 7 years ago

Closing this, but feel free to reopen if you think it necessary.