From 13aa0fd8330156e4e13297a260554a7028b8d377 Mon Sep 17 00:00:00 2001 From: funman300 Date: Sat, 2 May 2026 01:03:12 +0000 Subject: [PATCH] =?UTF-8?q?fix(engine):=20match=20CARD=5FASPECT=20to=20hay?= =?UTF-8?q?eah=20SVG=20dimensions=20(1.4=20=E2=86=92=201.4523)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cards rendered ~3.6 % squashed vertically because layout.rs assumed a 1.4 height/width ratio while the bundled hayeah/playing-cards-assets SVGs are natively 167.087 × 242.667 (= 1.4523). The mismatch meant every face was scaled to fit a too-short box; pip arrangements and court-card art read slightly compressed. Bumps CARD_ASPECT to 1.4523 to match the SVG. The vertical-budget math in compute_layout (the height-based card_width candidate) uses CARD_ASPECT algebraically, so the tableau-fits-on-screen check adapts automatically — slightly smaller cards on aspect-ratio-tight windows, no visible regression on standard 16:9. Doc comments referencing the old 1.4 literal updated to point at CARD_ASPECT instead so this can't drift again. All 982 tests pass — the existing layout/test sentinel (card_size.y / card_size.x - CARD_ASPECT) used the constant by name and adapted for free. Co-Authored-By: Claude Opus 4.7 (1M context) --- solitaire_engine/src/layout.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/solitaire_engine/src/layout.rs b/solitaire_engine/src/layout.rs index 764c167..33f2444 100644 --- a/solitaire_engine/src/layout.rs +++ b/solitaire_engine/src/layout.rs @@ -26,7 +26,11 @@ pub enum LayoutSystem { pub const MIN_WINDOW: Vec2 = Vec2::new(800.0, 600.0); /// Aspect ratio (height / width) of a standard playing card. -const CARD_ASPECT: f32 = 1.4; +/// +/// Matches the bundled hayeah/playing-cards-assets SVG dimensions +/// (167.087 × 242.667 → 1.4523). Pre-v0.11 the constant was 1.4, +/// which rendered the cards ~3.6 % squashed vertically. +const CARD_ASPECT: f32 = 1.4523; /// Fraction of card height used as vertical padding between the top row and /// the tableau row. @@ -59,7 +63,7 @@ pub const TABLE_COLOUR: [f32; 3] = [0.059, 0.322, 0.196]; pub struct Layout { /// Width and height of a single card, in world units (Bevy 2D world-space). /// - /// `x` is the card width; `y` is the card height (always `x * 1.4`). + /// `x` is the card width; `y` is the card height (`x * CARD_ASPECT`). /// All pile positions and fan offsets are derived from this value. pub card_size: Vec2, /// Centre position of each pile, in 2D world coordinates. @@ -80,7 +84,8 @@ pub struct Layout { /// column (13 face-up cards, see [`MAX_TABLEAU_CARDS`]) inside the /// window with a bottom margin equal to `h_gap`. Limiter on tall/narrow /// windows. -/// - `card_height = card_width * 1.4`. +/// - `card_height = card_width * CARD_ASPECT` (1.4523, matches the +/// bundled hayeah card art's natural SVG dimensions). /// - Horizontal gap `h_gap = card_width / 4.0`. /// - Top row (stock, waste, 4 foundations) aligns with tableau columns /// 0, 1, 3, 4, 5, 6 — column 2 is intentionally empty to separate the