From 0b3b26d85f72612f8bedc21eb8004476929aa77e Mon Sep 17 00:00:00 2001 From: Drahoslav Date: Sun, 24 Dec 2017 12:44:25 +0100 Subject: [PATCH] Gofmt --- draw2d.go | 4 ++-- draw2dsvg/gc.go | 11 +++++++++-- font.go | 8 +++----- sync_test.go | 1 - 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/draw2d.go b/draw2d.go index 5905a4d..590a97e 100644 --- a/draw2d.go +++ b/draw2d.go @@ -130,8 +130,8 @@ const ( func (cap LineCap) String() string { return map[LineCap]string{ - RoundCap: "round", - ButtCap: "cap", + RoundCap: "round", + ButtCap: "cap", SquareCap: "square", }[cap] } diff --git a/draw2dsvg/gc.go b/draw2dsvg/gc.go index 212bd49..fbaf6f4 100644 --- a/draw2dsvg/gc.go +++ b/draw2dsvg/gc.go @@ -132,8 +132,6 @@ func toSvgPathDesc(p *draw2d.Path) string { // TODO move elsewhere nom := math.Hypot(ry*cosfi, rx*sinfi) x := cx + (rx*ry*cosfi)/nom y := cy + (rx*ry*sinfi)/nom - x += 0.001 // dirty hack to ensure whole arc is drawn if start point equals endpoint - y += 0.001 // compute large and sweep flags large := 0 @@ -144,6 +142,15 @@ func toSvgPathDesc(p *draw2d.Path) string { // TODO move elsewhere if !math.Signbit(ps[5]) { sweep = 1 } + // dirty hack to ensure whole arc is drawn + // if start point equals end point + if sweep == 1 { + x += 0.001 * sinfi + y += 0.001 * -cosfi + } else { + x += 0.001 * sinfi + y += 0.001 * cosfi + } // rx ry x-axis-rotation large-arc-flag sweep-flag x y parts[i] = fmt.Sprintf("A %.4f %.4f %v %v %v %.4f %.4f", diff --git a/font.go b/font.go index 90ef9a1..f5c9a04 100644 --- a/font.go +++ b/font.go @@ -8,8 +8,8 @@ import ( "log" "path/filepath" - "sync" "github.com/golang/freetype/truetype" + "sync" ) // FontStyle defines bold and italic styles for the font @@ -125,7 +125,7 @@ type FolderFontCache struct { namer FontFileNamer } -// NewFolderFontCache creates FolderFontCache +// NewFolderFontCache creates FolderFontCache func NewFolderFontCache(folder string) *FolderFontCache { return &FolderFontCache{ fonts: make(map[string]*truetype.Font), @@ -168,9 +168,7 @@ type SyncFolderFontCache struct { namer FontFileNamer } - - -// NewSyncFolderFontCache creates SyncFolderFontCache +// NewSyncFolderFontCache creates SyncFolderFontCache func NewSyncFolderFontCache(folder string) *SyncFolderFontCache { return &SyncFolderFontCache{ fonts: make(map[string]*truetype.Font), diff --git a/sync_test.go b/sync_test.go index 6c5afd8..8580a81 100644 --- a/sync_test.go +++ b/sync_test.go @@ -2,7 +2,6 @@ package draw2d_test - import ( "fmt" "github.com/llgcode/draw2d"