Skip to content

Commit 9d5a1fa

Browse files
authored
docs: add comment block explaining isometric projection math in layou… (JhaSourav07#956)
Closes JhaSourav07#376 ## Description Added an inline comment block in `lib/svg/layout.ts` right above the `towers.push` statement to clearly explain the mathematical logic behind the 2D-to-3D isometric projection grid mechanics and why the specific scale values (300, 120, 16, 9) were chosen. Fixes # 376 ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [ ] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents e9c0f3d + c764b27 commit 9d5a1fa

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/svg/layout.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ export function computeTowers(
103103
? `TODAY: ${day.date}: ${count} ${unit}`
104104
: `${day.date}: ${count} ${unit}`;
105105

106+
// Isometric projection: Maps 2D grid coordinates (i, j) to a 3D isometric screen space.
107+
// - Origin: (300, 120) anchors the grid layout on the SVG canvas.
108+
// - Indices: 'i' represents the week/column index; 'j' represents the day/row index.
109+
// - Geometry:
110+
// * (i - j) * 16 handles the horizontal shift. Increasing 'i' moves right; increasing 'j' moves left.
111+
// * (i + j) * 9 handles the vertical depth. Both indices move the tile downward.
112+
// - Constants: 16 and 9 represent half-widths and half-heights of the diamond tiles,
113+
// maintaining a clean ~2:1 aspect ratio for isometric perspective.
106114
towers.push({
107115
x: 300 + (i - j) * 16,
108116
y: 120 + (i + j) * 9,

0 commit comments

Comments
 (0)