fix(svg): consolidate hardcoded geometry parameters into layout constants#6129
Closed
hardik-bhalekar wants to merge 1 commit into
Closed
fix(svg): consolidate hardcoded geometry parameters into layout constants#6129hardik-bhalekar wants to merge 1 commit into
hardik-bhalekar wants to merge 1 commit into
Conversation
Contributor
|
@hardik-bhalekar is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
👋 Hey @hardik-bhalekar! Thanks for your contribution! 🎉 Unfortunately, this PR has been automatically closed because it is not linked to any open issue. To resolve this, please do the following:
We look forward to reviewing your PR once an issue is linked! 🚀 |
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.
Summary
Consolidates hardcoded isometric geometry magic numbers (
16,10,20,8) scattered acrossgenerator.tsinto named constants inlayoutConstants.ts, eliminating layout fragmentation caused by inconsistent values and making the SVG projection layer maintainable.Problem
The SVG isometric rendering pipeline uses several geometry parameters (tile half-width, tile half-height, full tile height, label offsets) that were duplicated as raw numeric literals across
buildTowerPaths(),renderIsometricLabels(), andgenerateLanguagesSVG(). This led to:16,10,20was unclear without contextISOMETRIC_VERTICAL_OFFSETwas a localconstingenerator.tswhileTILE_WIDTH_HALF/TILE_HEIGHT_HALFwere already exported fromlayoutConstants.tsChanges
lib/svg/layoutConstants.tsAdded 5 new exported constants:
TILE_FULL_HEIGHT20TILE_DIAGONAL_HALF8GRID_CELL_SIZE16MONTH_LABEL_OFFSET_X8ISOMETRIC_LABEL_VERTICAL_OFFSET20lib/svg/generator.tsbuildTowerPaths()16 * scale,10 * scale,20 * scaleTILE_WIDTH_HALF * scale,TILE_HEIGHT_HALF * scale,TILE_FULL_HEIGHT * scaleconst ISOMETRIC_VERTICAL_OFFSET = 20layoutConstants.ts)renderIsometricLabels()month labels+ 8andISOMETRIC_VERTICAL_OFFSETMONTH_LABEL_OFFSET_XandISOMETRIC_LABEL_VERTICAL_OFFSETrenderIsometricLabels()weekday labelsISOMETRIC_VERTICAL_OFFSET+Math.round(20 * sf)ISOMETRIC_LABEL_VERTICAL_OFFSETthroughoutgenerateLanguagesSVG()10 * towerScaleTILE_HEIGHT_HALF * towerScaleTesting
npx tsc --noEmitpasses with zero errorslayoutConstants.ts