Skip to content

render_mpl and render_animation ignore ViewState.zoom #46

@bjmorgan

Description

@bjmorgan

Summary

The auto-fit viewport path in _draw_scene computes axis limits from the projected bounding box of all atoms. Since ViewState.zoom scales the projected coordinates, a larger zoom produces a proportionally larger bounding box -- the viewport expands to fit and the zoom has no visible effect.

This means:

  • Setting view.zoom in the interactive viewer, then calling render_mpl() produces the same output regardless of zoom level.
  • The intended workflow of "dial in the view interactively, then render" does not work for zoom.
  • render_animation inherits the same issue.

Rotation, pan (view.centre), and perspective are all respected correctly. Only zoom is broken in the auto-fit path.

Expected behaviour

zoom > 1 should show a cropped/zoomed-in view of the scene. zoom < 1 should show the scene with more padding around it.

Root cause

_draw_scene in painter.py (auto-fit path, lines ~800-805) computes pad_x and pad_y from the projected coordinates, which already have zoom applied via ViewState.project(). The zoom scales both the coordinates and the bounding box equally, so they cancel out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions