Skip to content

Commit

Permalink
Apply the thin line fix for LowDPI displays
Browse files Browse the repository at this point in the history
Fixes #2298
  • Loading branch information
andydotxyz committed Aug 9, 2021
1 parent 163194d commit 8c44e9e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/painter/gl/draw.go
Expand Up @@ -117,14 +117,18 @@ func (p *glPainter) lineCoords(pos, pos1, pos2 fyne.Position, lineWidth, feather
pos2.X = roundToPixel(pos2.X+xPosDiff, p.pixScale)
pos2.Y = roundToPixel(pos2.Y+yPosDiff, p.pixScale)

if lineWidth <= 0.5 && p.pixScale > 1 { // adjust to support 1px drawing on HiDPI (width 0.5)
if lineWidth <= 1 {
offset := float32(0.5) // adjust location for lines < 1pt on regular display
if lineWidth <= 0.5 && p.pixScale > 1 { // and for 1px drawing on HiDPI (width 0.5)
offset = 0.25
}
if pos1.X == pos2.X {
pos1.X -= 0.25
pos2.X -= 0.25
pos1.X -= offset
pos2.X -= offset
}
if pos1.Y == pos2.Y {
pos1.Y -= 0.25
pos2.Y -= 0.25
pos1.Y -= offset
pos2.Y -= offset
}
}

Expand Down

0 comments on commit 8c44e9e

Please sign in to comment.