Skip to content

Draw image grams one image pixel per screen pixel, fitted to the page (#345) - #347

Merged
IanMayo merged 3 commits into
mainfrom
claude/intelligent-faraday-14ms81
Oct 2, 2026
Merged

IanMayo merged 3 commits into
mainfrom
claude/intelligent-faraday-14ms81

Conversation

@IanMayo

@IanMayo IanMayo commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #345.

Diagnosis

I couldn't reproduce the stretch at 1× device scaling. The likely cause is display scaling. On a Windows display set to 125% or 150%, one CSS pixel is 1.25–1.5 screen pixels, so a gram drawn at its natural CSS size shows half as big again as the image, axis labels included. The old rule also capped width at a fixed 1200 CSS px whatever room the page had. That cap is why the "before" gram fills a 125%-scaled 1920 screen (about 1536 CSS px wide) but leaves a gap on a wider one.

Change

  • New default (screen). A gram is drawn at one image pixel per screen pixel (÷ devicePixelRatio). It is shrunk, keeping its shape, only when that would not fit the page width, and it refits on resize.
  • Expand button on every image gram. Portrait snippets and verniers now get the button too, and expand the way landscape grams do (fill width and height).
  • Optional image-sizing row. It overrides the default per gram:
    • screen (default)
    • native: one image px per CSS px, same fit
    • legacy: the old 1200 cap, with the expand button on landscape grams only
  • Errors. An unknown value is reported on the page like any other config error.
  • Unchanged. The chosen size becomes the gram's base size, as the legacy down-scale always did, so zoom, expand and the coordinate transforms are untouched.

Preview

demo/image-sizing.html (linked from the landing page) shows a 1677×380 gram and a 357×366 snippet cut from it. The first two grams are pinned to legacy; the last two have no row, so they show the default. The page reports the display's scale factor, the window width and each gram's drawn size.

Tests

  • Vitest: fitImageSize across all sizings, using the issue's image sizes.
  • Playwright image-sizing.spec.js: covers six things.
    • native fits a 1000px window.
    • It grows back to full width at 1900px.
    • legacy stays at 1200.
    • The snippet gets the toggle (and none under legacy), and it expands and collapses.
    • A table with no row draws a 240×480 vernier at 120×240 on a 2× display.
    • An invalid value shows the error box.
  • Existing specs adjusted:
    • image-scaling.spec.js still covers the 1200 cap; debug-multiple.html pins its large gram to legacy for it.
    • The SC-005 portrait guard now expects the toggle on the vernier.
  • Full suite: 539 passed. typecheck, lint, hygiene and check:site are clean.
  • Docs: the row is added to docs/HTML-Integration-Guide.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_016EDJhgnsnPokKFevLu1a3X

A gram's image was drawn at one image pixel per CSS pixel, capped at
1200 CSS px whatever room the page had. On a display scaled to 125% or
150% a CSS pixel is 1.25-1.5 screen pixels, so a 357x366 snippet is
drawn half as big again as the image, labels included; and a wide gram
overflows any page narrower than the cap.

The optional `image-sizing` config row chooses the strategy, so
stakeholders can compare before one is made permanent:
- legacy (default, unchanged behaviour)
- native: one image pixel per CSS pixel, shrunk to fit the room
- screen: one image pixel per screen pixel, shrunk to fit the room

The fitting sizes refit on resize. demo/image-sizing.html shows a
1677x380 gram and a 357x366 snippet cut from it, before and after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EDJhgnsnPokKFevLu1a3X
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Preview

Preview deployment is ready! View Preview

Last updated: 2026-10-02T13:22:48.411Z

claude added 2 commits October 2, 2026 12:47
Under `native` and `screen` every image gram gets the expand button, the
357x366 snippet included, and expands as a landscape gram does. Legacy
keeps the landscape-only gate, so verniers on existing pages are
unchanged. The demo page now reports the window width beside the scale
factor, since that is what decides how much of the page the legacy
1200 px gram fills.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EDJhgnsnPokKFevLu1a3X
A gram whose table has no `image-sizing` row is now drawn one image
pixel per screen pixel, shrunk only to fit the page's width, and gets
the expand toggle whatever its shape. `legacy` remains as an explicit
opt-out: debug-multiple.html pins its large gram to it so the 1200 px
cap stays covered, and the demo page's "before" grams name it.

The portrait-guard test (SC-005) now expects the toggle on the vernier,
and the integration guide documents the row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EDJhgnsnPokKFevLu1a3X
@IanMayo IanMayo changed the title Add an image-sizing trial row for small grams drawn too big (#345) Draw image grams one image pixel per screen pixel, fitted to the page (#345) Oct 2, 2026
@IanMayo
IanMayo merged commit 940ce44 into main Oct 2, 2026
6 checks passed
@IanMayo
IanMayo deleted the claude/intelligent-faraday-14ms81 branch October 2, 2026 14:00
github-actions Bot added a commit that referenced this pull request Oct 2, 2026
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.

Small-ish issue gets hugely stretched

2 participants