Fix frame order - #2
Open
bbcuffer wants to merge 5 commits into
Open
Conversation
Modulo arithmetic moved the final frame from last to first. .frame was frame-number %% number-of-frames (which is zero for the final frame - ie first when sorted on .frame) fix is to use (frame-number - 1) %% number-of-frames Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two issues caused frames to be distributed unequally across pauses and transitions, making wrap=FALSE animations zoom back and wrap=TRUE animations spend more time pausing than transitioning. Issue 1 — setup_params: an unnecessary phase for pause_first=FALSE The phase vectors were built by prepending a zero-pause slot and appending a zero-step slot, then conditionally zeroing elements: pause_length <- c(0, pause_length) # e.g. c(0, 1, 1) step_length <- c(step_length, 0) # e.g. c(1, 1, 0) if (!wrap) pause_length[last] <- 0 # e.g. c(0, 1, 0) for wrap=FALSE For wrap=FALSE this made no difference. It left a dead (0, 0) trailing phase; for wrap=TRUE it left a live (1, 0) trailing phase that allocated frames to a w1 pause that should not exist (the gif loop provides that continuity). Fix: drop the append entirely and trim the last pause in one step: pause_length <- c(0, pause_length[-length(pause_length)]) The behaviour becomes: wrap=FALSE: pause=c(0,1) step=c(1,0) — transition then freeze wrap=TRUE: pause=c(0,1) step=c(1,1) — transition, pause, return Bug 2 — train: nframes inflated by 1 for wrap=TRUE if (params$wrap) nframes <- nframes + 1 This made distribute_frames divide one extra frame across all phases, which in practice biased allocation toward pauses. Wrap is already handled by padding params$windows with the first window row; the inflated nframes was not needed and is removed. Adds tests for all four wrap/pause_first combinations covering both the phase structure produced by setup_params and the resulting frame allocation from distribute_frames. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removes redundant nesting of if statements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes two issues on gganimate and enables simplification of bbanim code.
Combo of PRs
thomasp85#525
thomasp85#524
fixing issues
thomasp85#499
thomasp85#498