Fix scanline loop-point flicker with an instantaneous snap-back
The ramp-end keyframe and the next cycle's snap-back-to-0 keyframe were one tick apart, which got linearly interpolated -- for that one tick the pattern sat at a fractional, not-quite-zero offset instead of cleanly snapping, producing a brief flicker at each loop point. Fixed by giving both keyframes the exact same percentage (a zero-duration jump) instead. Also drops payload (425KB -> 364KB on the same test render) by removing a redundant near-duplicate frame per cycle.
This commit is contained in:
1 parent
90870f4a24
commit
927a23e557
1 file changed
+8
-2
@@ -611,16 +611,22 @@ def _glitch_scanlines():
|
|||||||
lines.append(render.Box(width = ART_SLOT, height = 1, color = "#00000000"))
|
lines.append(render.Box(width = ART_SLOT, height = 1, color = "#00000000"))
|
||||||
pattern = render.Column(children = lines)
|
pattern = render.Column(children = lines)
|
||||||
|
|
||||||
|
# The ramp's end and the next cycle's snap-back share the exact same
|
||||||
|
# percentage (a zero-duration jump), rather than the snap landing one
|
||||||
|
# tick later -- that one-tick gap got linearly interpolated, which
|
||||||
|
# for a single tick showed the pattern at a fractional, not-quite-0
|
||||||
|
# offset instead of cleanly snapping, producing a brief flicker right
|
||||||
|
# at the loop point.
|
||||||
keyframes = []
|
keyframes = []
|
||||||
for cycle in range(SCANLINE_CYCLES):
|
for cycle in range(SCANLINE_CYCLES):
|
||||||
cycle_start = cycle * _SCANLINE_CYCLE_TICKS
|
cycle_start = cycle * _SCANLINE_CYCLE_TICKS
|
||||||
ramp_end = cycle_start + _SCANLINE_CYCLE_TICKS - 1 # last tick of the cycle is the snap back to 0
|
cycle_end = cycle_start + _SCANLINE_CYCLE_TICKS # == next cycle's cycle_start
|
||||||
keyframes.append(animation.Keyframe(
|
keyframes.append(animation.Keyframe(
|
||||||
percentage = float(cycle_start) / SCANLINE_SWEEP_DURATION,
|
percentage = float(cycle_start) / SCANLINE_SWEEP_DURATION,
|
||||||
transforms = [animation.Translate(0, 0)],
|
transforms = [animation.Translate(0, 0)],
|
||||||
))
|
))
|
||||||
keyframes.append(animation.Keyframe(
|
keyframes.append(animation.Keyframe(
|
||||||
percentage = float(ramp_end) / SCANLINE_SWEEP_DURATION,
|
percentage = float(cycle_end) / SCANLINE_SWEEP_DURATION,
|
||||||
transforms = [animation.Translate(0, SCANLINE_SPACING)],
|
transforms = [animation.Translate(0, SCANLINE_SPACING)],
|
||||||
curve = "linear",
|
curve = "linear",
|
||||||
))
|
))
|
||||||
|
|||||||