Skip to content

Commit c764b27

Browse files
author
Sameeksha Katiyar
committed
docs: add comment block explaining isometric projection math in layout.ts JhaSourav07#376
1 parent 9b64cab commit c764b27

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
@@ -134,6 +134,14 @@ export function computeTowers(
134134
? `TODAY: ${day.date}: ${day.contributionCount} contributions`
135135
: `${day.date}: ${day.contributionCount} contributions`;
136136

137+
// Isometric projection: Maps 2D grid coordinates (i, j) to a 3D isometric screen space.
138+
// - Origin: (300, 120) anchors the grid layout on the SVG canvas.
139+
// - Indices: 'i' represents the week/column index; 'j' represents the day/row index.
140+
// - Geometry:
141+
// * (i - j) * 16 handles the horizontal shift. Increasing 'i' moves right; increasing 'j' moves left.
142+
// * (i + j) * 9 handles the vertical depth. Both indices move the tile downward.
143+
// - Constants: 16 and 9 represent half-widths and half-heights of the diamond tiles,
144+
// maintaining a clean ~2:1 aspect ratio for isometric perspective.
137145
towers.push({
138146
x: 300 + (i - j) * 16,
139147
y: 120 + (i + j) * 9,

0 commit comments

Comments
 (0)