Skip to content

Commit

Permalink
fix gopher position in all resolutions
Browse files Browse the repository at this point in the history
related to issue #3
  • Loading branch information
stapelberg committed Dec 27, 2022
1 parent 854b4ed commit c0a6005
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fbstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ func newStatusDrawer(img draw.Image) (*statusDrawer, error) {
w := bounds.Max.X
h := bounds.Max.Y

scaleFactor := math.Floor(float64(w) / 1024)
if scaleFactor < 1 {
scaleFactor = 1
}
log.Printf("font scale factor: %.f", scaleFactor)

// draw the gokrazy gopher image
gokrazyLogo, _, err := image.Decode(bytes.NewReader(gokrazyLogoPNG))
if err != nil {
Expand All @@ -121,7 +127,7 @@ func newStatusDrawer(img draw.Image) (*statusDrawer, error) {
draw.Draw(buffer, bounds, &image.Uniform{bgcolor}, image.Point{}, draw.Src)

// place the gopher in the top right half (centered)
const borderTop = 150
borderTop := int(50 * scaleFactor)
gopherRect := scaleImage(gokrazyLogo.Bounds(), w/2, h/2-borderTop)
gopherRect = gopherRect.Add(image.Point{w / 2, 0})
padX := ((w / 2) - gopherRect.Size().X) / 2
Expand All @@ -143,11 +149,6 @@ func newStatusDrawer(img draw.Image) (*statusDrawer, error) {
}

size := float64(16)
scaleFactor := math.Floor(float64(w) / 1024)
if scaleFactor < 1 {
scaleFactor = 1
}
log.Printf("font scale factor: %.f", scaleFactor)
size *= scaleFactor
face := truetype.NewFace(font, &truetype.Options{Size: size})
g.SetFontFace(face)
Expand Down

0 comments on commit c0a6005

Please sign in to comment.