Skip to content

SVG: add Size fit-height + fix animated-SVG frame quantization - #5

Merged
phil-scott-78 merged 2 commits into
mainfrom
feat/svg-fit-height-and-frame-quantize
Jun 14, 2026
Merged

SVG: add Size fit-height + fix animated-SVG frame quantization#5
phil-scott-78 merged 2 commits into
mainfrom
feat/svg-fit-height-and-frame-quantize

Conversation

@phil-scott-78

Copy link
Copy Markdown
Owner

Summary

Two related improvements to the browserless SVG renderer, each with tests.

feat: Size fit-height — crop height, keep grid width

Set Size "fit-height" (alias fit-rows) trims trailing blank rows but keeps the full grid width (Cols × cell width) instead of cropping to the content's right edge like plain fit does.

The motivation: when you generate a batch of SVG screenshots and scale them to a fixed display width, plain fit gives each one a different intrinsic width, so the apparent font size jumps from image to image. fit-height pins a uniform width across the batch while still trimming vertical whitespace.

  • Implies FitToContent.
  • Grows, never shrinks — content wider than Cols is still contained, never clipped (SetContentExtent takes Math.Max(cols, Cols)).
  • ApplySetting and the SettingDeprecations typo lint both normalize separators/case, so fit-height, fit_height, fitheight, and fit-rows all validate without a spurious "not recognized" warning.

fix: keep the settled frame, not the torn one, when quantizing animated SVG

QuantizeToFramerate now keeps the last state in each 1/fps window instead of the first.

Event-driven capture records a screen redraw (a table scrolling in, a TUI repaint) as a short-lived torn intermediate frame immediately followed — often only ~10–15 ms later, inside the same window — by the settled frame. Keeping the first froze the tear for a whole display slot (e.g. a 2 s plateau), producing visible corruption where rows from two different screens overlap. Keeping the last drops the transient and shows the settled screen, which is also what the un-quantized raster/GIF path effectively displays. The first and final frames are still always kept.

Testing

  • dotnet build VcrSharp.sln — clean (0 warnings, 0 errors)
  • New SvgQuantizeTests (transient-then-settled, final-frame-kept, continuous-stream down-sampling, passthrough) and SettingDeprecationsTests.Collect_DoesNotFlagFitHeightSizeVariants — all green (14/14 in the touched classes).

Set Size "fit-height" (alias fit-rows) trims trailing blank rows but keeps the
full Cols width, so a batch of SVG screenshots shares one width — and thus a
constant apparent font size when scaled to a fixed display width. Implies
FitToContent and grows, never shrinks, so content wider than Cols isn't clipped.

ApplySetting and the SettingDeprecations typo lint both normalize separators/case,
so fit-height, fit_height, fitheight, and the fit-rows alias all validate.
…ed SVG

QuantizeToFramerate now keeps the LAST state in each 1/fps window instead of the
first. Event-driven capture records a screen redraw as a short-lived torn frame
immediately followed (~10-15ms later, inside one window) by the settled frame.
Keeping the first froze that tear for a full display slot — rows from two screens
overlapping. Keeping the last drops the transient and shows the settled screen,
matching what the raster/GIF path effectively displays. The first and final
frames are still always kept.
@phil-scott-78
phil-scott-78 merged commit 4ce677b into main Jun 14, 2026
2 checks passed
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.

1 participant