fix(engine): match CARD_ASPECT to hayeah SVG dimensions (1.4 → 1.4523)
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user