Skip to content

Commit e0b1344

Browse files
Merge pull request #11 from github/martin-updates
Model tweaks
2 parents 9fdfe3f + 58d8920 commit e0b1344

4 files changed

Lines changed: 13 additions & 21 deletions

File tree

stl/generator.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,7 @@ func calculateDimensions(yearCount int) (modelDimensions, error) {
9696
}
9797

9898
var width, depth float64
99-
100-
if yearCount <= 1 {
101-
// Single year case: add padding to both width and depth
102-
width = float64(geometry.GridSize)*geometry.CellSize + 2*geometry.CellSize
103-
depth = float64(7)*geometry.CellSize + 2*geometry.CellSize
104-
} else {
105-
// Multi-year case: use the multi-year calculation
106-
width, depth = geometry.CalculateMultiYearDimensions(yearCount)
107-
}
99+
width, depth = geometry.CalculateMultiYearDimensions(yearCount)
108100

109101
dims := modelDimensions{
110102
innerWidth: width,
@@ -216,8 +208,8 @@ func generateText(username string, startYear int, endYear int, dims modelDimensi
216208

217209
// If start year and end year are the same, only show one year
218210
if startYear != endYear {
219-
// Make the year 'YY-YY'
220-
embossedYear = fmt.Sprintf("'%02d-'%02d", startYear%100, endYear%100)
211+
// Make the year 'YYYY-YY'
212+
embossedYear = fmt.Sprintf("%04d-%02d", startYear, endYear%100)
221213
}
222214

223215
textTriangles, err := geometry.Create3DText(username, embossedYear, dims.innerWidth, geometry.BaseHeight)

stl/geometry/geometry.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ func CreateContributionGeometry(contributions [][]types.ContributionDay, yearInd
6767
var triangles []types.Triangle
6868

6969
// Base Y offset includes padding and positions each year accordingly
70-
baseYOffset := CellSize + float64(yearIndex)*7*CellSize
70+
baseYOffset := 2*CellSize + float64(yearIndex)*7*CellSize
7171

7272
for weekIdx, week := range contributions {
7373
for dayIdx, day := range week {
7474
if day.ContributionCount > 0 {
7575
height := NormalizeContribution(day.ContributionCount, maxContrib)
76-
x := CellSize + float64(weekIdx)*CellSize
76+
x := 2*CellSize + float64(weekIdx)*CellSize
7777
y := baseYOffset + float64(dayIdx)*CellSize
7878

7979
columnTriangles, err := CreateColumn(x, y, height, CellSize)
@@ -91,8 +91,8 @@ func CreateContributionGeometry(contributions [][]types.ContributionDay, yearInd
9191
// CalculateMultiYearDimensions calculates dimensions for multiple years
9292
func CalculateMultiYearDimensions(yearCount int) (width, depth float64) {
9393
// Total width: grid size + padding on both sides
94-
width = float64(GridSize)*CellSize + 2*CellSize
94+
width = float64(GridSize)*CellSize + 4*CellSize
9595
// Total depth: (7 days * number of years) + padding on both sides
96-
depth = float64(7*yearCount)*CellSize + 2*CellSize
96+
depth = float64(7*yearCount)*CellSize + 4*CellSize
9797
return width, depth
9898
}

stl/geometry/geometry_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ func TestCalculateMultiYearDimensions(t *testing.T) {
9090
wantW float64
9191
wantD float64
9292
}{
93-
{"single year", 1, float64(GridSize)*CellSize + 2*CellSize, 7*CellSize + 2*CellSize},
94-
{"multiple years", 3, float64(GridSize)*CellSize + 2*CellSize, 21*CellSize + 2*CellSize},
95-
{"zero years", 0, float64(GridSize)*CellSize + 2*CellSize, 2 * CellSize},
93+
{"single year", 1, float64(GridSize)*CellSize + 4*CellSize, 7*CellSize + 4*CellSize},
94+
{"multiple years", 3, float64(GridSize)*CellSize + 4*CellSize, 21*CellSize + 4*CellSize},
95+
{"zero years", 0, float64(GridSize)*CellSize + 4*CellSize, 4 * CellSize},
9696
}
9797

9898
for _, tt := range tests {

stl/geometry/text.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type imageRenderConfig struct {
3838
const (
3939
imagePosition = 0.025
4040
usernameOffset = -0.01
41-
yearPosition = 0.79
41+
yearPosition = 0.77
4242

4343
defaultContextWidth = 800
4444
defaultContextHeight = 200
@@ -143,9 +143,9 @@ func renderText(config textRenderConfig) ([]types.Triangle, error) {
143143
xPos,
144144
config.startY,
145145
zPos,
146-
config.voxelScale,
146+
config.voxelScale/2,
147147
config.depth,
148-
config.voxelScale,
148+
config.voxelScale/2,
149149
)
150150
if err != nil {
151151
return nil, errors.New(errors.STLError, "failed to create cube", err)

0 commit comments

Comments
 (0)