Skip to content

fix(deck): scale key icons symmetrically (aspect-preserving contain fit) - #595

Merged
danshapiro merged 1 commit into
mainfrom
feat/deck-icon-aspect
Aug 1, 2026
Merged

fix(deck): scale key icons symmetrically (aspect-preserving contain fit)#595
danshapiro merged 1 commit into
mainfrom
feat/deck-icon-aspect

Conversation

@danshapiro

Copy link
Copy Markdown
Owner

Summary

Repo and agent pane icons on Stream Deck keys were drawn with drawImage(bitmap, x, y, size, size), mapping the whole source image into the square icon slot — any non-square icon got scaled independently per axis and stretched.

  • Add containIconRect(): computes the largest centered rect with the bitmap's intrinsic aspect ratio inside the square slot, so icons only ever scale symmetrically (letterboxed/pillarboxed instead of stretched).
  • Both draw sites (repo icons, tinted agent pane icons) route through a shared drawIconContained() helper.
  • Dimensionless (viewBox-only) SVGs report 0x0 intrinsics and keep the existing full-square fallback, preserving the mandatory explicit 5-arg drawImage rule that guards the drawn-blank SVG trap (repo_icon_detect.rs serves dimensionless SVGs first-class).

Testing

  • New unit tests: contain-fit geometry (wide/tall/square/dimensionless/extreme aspect, naturalWidth preference) plus renderKey integration for both repo-icon and pane-icon draw paths.
  • npm run test:unit: 378 files / 4560 tests passed.
  • npm run typecheck clean; eslint clean on touched files.

Generated with Amplifier

Repo and agent pane icons on Stream Deck keys were drawn with
drawImage(bitmap, x, y, size, size), mapping the whole source into a
square slot and stretching any non-square icon asymmetrically.

Add containIconRect: the largest centered rect with the bitmap's
intrinsic aspect ratio inside the square slot, so icons only ever scale
symmetrically. Dimensionless (viewBox-only) SVGs report 0x0 intrinsics
and keep the full-square fallback, preserving the mandatory explicit
5-arg drawImage rule that guards the drawn-blank SVG trap.

Generated with Amplifier

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@danshapiro
danshapiro merged commit 35fbf13 into main Aug 1, 2026
3 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