Skip to content

Fix frame distribution in view_step_manual() - #525

Open
bbcuffer wants to merge 3 commits into
thomasp85:mainfrom
bbcuffer:i499
Open

Fix frame distribution in view_step_manual()#525
bbcuffer wants to merge 3 commits into
thomasp85:mainfrom
bbcuffer:i499

Conversation

@bbcuffer

Copy link
Copy Markdown

Fixes #499.

Logic in view_step_manual was allocating extra transitions for wrap = FALSE. More detail in the commit.

i499

bbcuffer and others added 2 commits June 22, 2026 14:22
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

view_step_manual() ignores wrap = FALSE

1 participant