feat: headless batch mode for PNG sequence rendering#12
Open
feat: headless batch mode for PNG sequence rendering#12
Conversation
Adds render_frame() to batch.rs backed by a new render::draw_protein() wrapper around the existing hd::render_hd_framebuffer() pipeline. Extracts parse_color_scheme() into render::color and VizMode::parse() into app, and adds build_highlight_map() for future hotspot integration.
- Replace float-equality sentinel (cam.zoom == 1.0) with Option A: always auto-fit to protein extent, treat waypoint zoom as a multiplier (zoom:1.0 = fill frame, zoom:2.0 = 2x zoomed in). Eliminates interpolated-value misfire hazard entirely. - Remove misleading `highlight_map` parameter reference from draw_protein doc; replace with Task 6 forward-reference note. - Add "not yet consumed by draw_protein; wired in Task 6" note to build_highlight_map doc so callers don't assume it has effect. - Add `use crate::model::protein::Protein` import; shorten render_frame signature from full crate path to bare `Protein`.
Implements `run()` as the top-level batch entrypoint: loads the protein, iterates frames 1..=N computing t via (i-1)/max(1,frames-1), interpolates camera via `camera_at`, renders via `render_frame`, and writes each frame as `frame_NNNN.png` to `output_dir` (created with `create_dir_all`). Adds `writes_png_sequence_to_output_dir` test: 5-frame sequence over a 160×120 render of 1UBQ.pdb, verifying all five PNGs land in a tempdir. 140/140 tests pass.
Add highlight_overrides field to ColorScheme with a with_highlights() builder method. residue_color() checks overrides first before the normal scheme logic, covering all render modes (cartoon via ribbon mesh, backbone, wireframe). render_frame() now converts HighlightMap into the ColorScheme override table instead of discarding it. Adds hotspot_residues_are_visibly_recolored test confirming red pixel count increases when hotspot covers first 20 residues of ubiquitin.
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.
Summary
--batch <CONFIG_JSON>mode that renders deterministic PNG sequences without entering the TUIBatchConfigJSON schema with camera waypoints (linearly interpolated across frames), hotspot residue highlights, and color/viz mode selectionrender::draw_protein()wrapper aroundhd::render_hd_framebuffer— TUI render path untouchedColorScheme::with_highlights()builder threads per-residue color overrides through the rendererexamples/batch_demo.json(60-frame 360° rotation @ 1920×1080 of histone nucleosome 1AOI)Use cases
Animation frames for video editing, automated CI screenshots, headless rendering for scripted pipelines.
Test plan
cargo test— 142/142 passing (141 unit + 1 integration test)cargo fmt --checkcleancargo build --releasecleanproteinview --batch examples/batch_demo.jsonrenders 60 PNGs at 1920×1080 in ~2.6shotspot_residues_are_visibly_recolored)Architecture note
The TUI's render orchestration in
Appis coupled withPicker, Sixel encoding, frame-skip logic, and auto-rotate. Rather than disentangle those for shared use with batch mode, this PR introduces a thin wrapperrender::draw_proteinthat batch calls directly while the TUI continues to callhd::render_hd_framebufferdirectly. Documented in a NOTE comment insrc/render/mod.rs. A future cleanup could unify the paths.Known follow-ups
BatchConfig.render_modefield is parsed but only the FullHD path is honored. Other modes accepted for forward compatibility but no-op. TODO comment in code.draw_protein(TUI caches it inApp.mesh_cache). For scripted multi-frame rendering, hoist mesh construction intobatch::runto cache once per protein.