diff --git a/stl/generator.go b/stl/generator.go index 7a43a4f..98cde8b 100644 --- a/stl/generator.go +++ b/stl/generator.go @@ -96,15 +96,7 @@ func calculateDimensions(yearCount int) (modelDimensions, error) { } var width, depth float64 - - if yearCount <= 1 { - // Single year case: add padding to both width and depth - width = float64(geometry.GridSize)*geometry.CellSize + 2*geometry.CellSize - depth = float64(7)*geometry.CellSize + 2*geometry.CellSize - } else { - // Multi-year case: use the multi-year calculation - width, depth = geometry.CalculateMultiYearDimensions(yearCount) - } + width, depth = geometry.CalculateMultiYearDimensions(yearCount) dims := modelDimensions{ innerWidth: width, @@ -216,8 +208,8 @@ func generateText(username string, startYear int, endYear int, dims modelDimensi // If start year and end year are the same, only show one year if startYear != endYear { - // Make the year 'YY-YY' - embossedYear = fmt.Sprintf("'%02d-'%02d", startYear%100, endYear%100) + // Make the year 'YYYY-YY' + embossedYear = fmt.Sprintf("%04d-%02d", startYear, endYear%100) } textTriangles, err := geometry.Create3DText(username, embossedYear, dims.innerWidth, geometry.BaseHeight) diff --git a/stl/geometry/geometry.go b/stl/geometry/geometry.go index 55c7868..e804771 100644 --- a/stl/geometry/geometry.go +++ b/stl/geometry/geometry.go @@ -67,13 +67,13 @@ func CreateContributionGeometry(contributions [][]types.ContributionDay, yearInd var triangles []types.Triangle // Base Y offset includes padding and positions each year accordingly - baseYOffset := CellSize + float64(yearIndex)*7*CellSize + baseYOffset := 2*CellSize + float64(yearIndex)*7*CellSize for weekIdx, week := range contributions { for dayIdx, day := range week { if day.ContributionCount > 0 { height := NormalizeContribution(day.ContributionCount, maxContrib) - x := CellSize + float64(weekIdx)*CellSize + x := 2*CellSize + float64(weekIdx)*CellSize y := baseYOffset + float64(dayIdx)*CellSize columnTriangles, err := CreateColumn(x, y, height, CellSize) @@ -91,8 +91,8 @@ func CreateContributionGeometry(contributions [][]types.ContributionDay, yearInd // CalculateMultiYearDimensions calculates dimensions for multiple years func CalculateMultiYearDimensions(yearCount int) (width, depth float64) { // Total width: grid size + padding on both sides - width = float64(GridSize)*CellSize + 2*CellSize + width = float64(GridSize)*CellSize + 4*CellSize // Total depth: (7 days * number of years) + padding on both sides - depth = float64(7*yearCount)*CellSize + 2*CellSize + depth = float64(7*yearCount)*CellSize + 4*CellSize return width, depth } diff --git a/stl/geometry/geometry_test.go b/stl/geometry/geometry_test.go index 3373aa5..fe9906a 100644 --- a/stl/geometry/geometry_test.go +++ b/stl/geometry/geometry_test.go @@ -90,9 +90,9 @@ func TestCalculateMultiYearDimensions(t *testing.T) { wantW float64 wantD float64 }{ - {"single year", 1, float64(GridSize)*CellSize + 2*CellSize, 7*CellSize + 2*CellSize}, - {"multiple years", 3, float64(GridSize)*CellSize + 2*CellSize, 21*CellSize + 2*CellSize}, - {"zero years", 0, float64(GridSize)*CellSize + 2*CellSize, 2 * CellSize}, + {"single year", 1, float64(GridSize)*CellSize + 4*CellSize, 7*CellSize + 4*CellSize}, + {"multiple years", 3, float64(GridSize)*CellSize + 4*CellSize, 21*CellSize + 4*CellSize}, + {"zero years", 0, float64(GridSize)*CellSize + 4*CellSize, 4 * CellSize}, } for _, tt := range tests { diff --git a/stl/geometry/text.go b/stl/geometry/text.go index 41556d6..65e83d0 100644 --- a/stl/geometry/text.go +++ b/stl/geometry/text.go @@ -38,7 +38,7 @@ type imageRenderConfig struct { const ( imagePosition = 0.025 usernameOffset = -0.01 - yearPosition = 0.79 + yearPosition = 0.77 defaultContextWidth = 800 defaultContextHeight = 200 @@ -143,9 +143,9 @@ func renderText(config textRenderConfig) ([]types.Triangle, error) { xPos, config.startY, zPos, - config.voxelScale, + config.voxelScale/2, config.depth, - config.voxelScale, + config.voxelScale/2, ) if err != nil { return nil, errors.New(errors.STLError, "failed to create cube", err)