Animations using after_draw() don't work properly #97
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Sparkle animation uses
after_draw
to setup the pixels currently being sparkled for the next frame, assumingshow()
will not be called until then. It also callsshow()
itself first to show the changes made indraw()
.The problem is that
animate()
already callsshow()
after calling draw and after_draw. So the frame where the sparkle should show is actually "skipped": it only briefly appears instead of staying for a frame according to the speed parameter. The refactor from PR #23 changed the protocol where animations should no longer callshow()
themselves.We can't change
after_draw
to be called after the call toshow()
inanimate()
, because it will break for example on animation groups using the same strip: if another animation triggers ashow()
, it will show the next frame of the sparkle prematurely. It also makes the protocol less predictable in general.This PR drops
after_draw()
altogether and instead does everything indraw()
.I don't think there is a need to preserve backwards compatibility with potential 3rd party animations using it, since it can't have worked properly since #23.