Skip to content

Commit

Permalink
Expand vector pad as required by expanding vector strokes
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jun 26, 2020
1 parent 2c280e7 commit 8fe1759
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions internal/painter/gl/draw.go
Expand Up @@ -79,10 +79,12 @@ func (p *glPainter) drawWidget(wid fyne.Widget, pos fyne.Position, frame fyne.Si
}

func (p *glPainter) drawCircle(circle *canvas.Circle, pos fyne.Position, frame fyne.Size) {
vectorPad := int(circle.StrokeWidth) + 2
p.drawTextureWithDetails(circle, p.newGlCircleTexture, pos, circle.Size(), frame, canvas.ImageFillStretch, 1.0, 0.0, vectorPad)
}

func (p *glPainter) drawLine(line *canvas.Line, pos fyne.Position, frame fyne.Size) {
vectorPad := int(line.StrokeWidth) + 2
p.drawTextureWithDetails(line, p.newGlLineTexture, pos, line.Size(), frame, canvas.ImageFillStretch, 1.0, 0.0, vectorPad)
}

Expand All @@ -103,11 +105,8 @@ func (p *glPainter) drawGradient(o fyne.CanvasObject, texCreator func(fyne.Canva
}

func (p *glPainter) drawRectangle(rect *canvas.Rectangle, pos fyne.Position, frame fyne.Size) {
pad := 0
if rect.StrokeColor != nil && rect.StrokeWidth > 0 {
pad = vectorPad
}
p.drawTextureWithDetails(rect, p.newGlRectTexture, pos, rect.Size(), frame, canvas.ImageFillStretch, 1.0, 0.0, pad)
vectorPad := int(rect.StrokeWidth) + 2
p.drawTextureWithDetails(rect, p.newGlRectTexture, pos, rect.Size(), frame, canvas.ImageFillStretch, 1.0, 0.0, vectorPad)
}

func (p *glPainter) drawText(text *canvas.Text, pos fyne.Position, frame fyne.Size) {
Expand Down
5 changes: 3 additions & 2 deletions internal/painter/gl/gl_common.go
Expand Up @@ -20,8 +20,6 @@ import (

var textures = make(map[fyne.CanvasObject]Texture, 1024)

const vectorPad = 10

func logGLError(err uint32) {
if err == 0 {
return
Expand All @@ -47,6 +45,7 @@ func getTexture(object fyne.CanvasObject, creator func(canvasObject fyne.CanvasO
func (p *glPainter) newGlCircleTexture(obj fyne.CanvasObject) Texture {
circle := obj.(*canvas.Circle)
radius := fyne.Min(circle.Size().Width, circle.Size().Height) / 2
vectorPad := int(circle.StrokeWidth) + 2

width := p.textureScaleInt(circle.Size().Width + vectorPad*2)
height := p.textureScaleInt(circle.Size().Height + vectorPad*2)
Expand All @@ -73,6 +72,7 @@ func (p *glPainter) newGlCircleTexture(obj fyne.CanvasObject) Texture {

func (p *glPainter) newGlLineTexture(obj fyne.CanvasObject) Texture {
line := obj.(*canvas.Line)
vectorPad := int(line.StrokeWidth) + 2

col := line.StrokeColor
width := p.textureScaleInt(line.Size().Width + vectorPad*2)
Expand Down Expand Up @@ -116,6 +116,7 @@ func (p *glPainter) newGlRectTexture(rect fyne.CanvasObject) Texture {

func (p *glPainter) newGlStrokedRectTexture(obj fyne.CanvasObject) Texture {
rect := obj.(*canvas.Rectangle)
vectorPad := int(rect.StrokeWidth) + 2

width := p.textureScaleInt(rect.Size().Width + vectorPad*2)
height := p.textureScaleInt(rect.Size().Height + vectorPad*2)
Expand Down

0 comments on commit 8fe1759

Please sign in to comment.