Add scale option in MeTTaGrapher - #8
Open
ngeiswei wants to merge 4 commits into
Open
Conversation
scale is a multiplier on the output width and height, applied after width is resolved from the view's default. It composes with an explicit width (scale: 2 with width: 240 produces 480 wide). The side-by-side view had a rounding drift: each panel and the gap were rounded independently, so cellW + gap + cellW could differ from the requested width by a pixel, and labelH + panelH could drift the same way. With scale that drift showed up as the doubled GIF being one pixel wider than 2x the base, and its height two pixels short. Derive the gap from the requested width (width - cellW * 2) and the labelH from the natural-scaled total height (totalH - panelH) so the output dimensions match the requested size exactly and scale produces linear dimensions.
scale must be a positive finite number. It is capped at 16 to keep the raster-pixel budget in check (width * height * numFrames must stay under the safety limit). The new tests verify that scale multiplies the output width by the requested factor across all three views (blocks, graph, side-by-side), and that it composes with an explicit width. Unsafe values (zero, negative, out of range) are rejected with a clear message.
metta graph already accepted --width for output resolution; --scale N is a multiplier on the same value, defaulting to 1. Without --width, scale multiplies the view's natural width (720 for blocks, 880 for graph, the computed natural width for side-by-side). With --width, scale multiplies that explicit width. The CLI validates the argument (positive finite number) before reaching the grapher so the user gets a clear error message. Usage: metta graph --scale 2 program.metta -o out.gif # 2x resolution metta graph --scale 0.5 program.metta -o out.gif # half resolution metta graph --width 240 --scale 3 program.metta # 240 x 3 = 720 wide Closes MesTTo#7
The node README picks up a one-line example of --scale 2. The node LLMS note mentions --scale=N next to the metta graph entry. The grapher LLMS note adds a 'scale multiplies the output pixel size' trap so callers who discover the option through the docs know it caps at 16.
Author
|
It's been 100% vibe coded by myself, and I'm pretty inexperienced about that so beware. I did test it and it works though. |
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.
This is a fix for issue #7.