This commit is contained in:
Drahoslav 2017-12-24 12:44:25 +01:00
parent 41d8a21ba2
commit 0b3b26d85f
4 changed files with 14 additions and 10 deletions

View File

@ -130,8 +130,8 @@ const (
func (cap LineCap) String() string { func (cap LineCap) String() string {
return map[LineCap]string{ return map[LineCap]string{
RoundCap: "round", RoundCap: "round",
ButtCap: "cap", ButtCap: "cap",
SquareCap: "square", SquareCap: "square",
}[cap] }[cap]
} }

View File

@ -132,8 +132,6 @@ func toSvgPathDesc(p *draw2d.Path) string { // TODO move elsewhere
nom := math.Hypot(ry*cosfi, rx*sinfi) nom := math.Hypot(ry*cosfi, rx*sinfi)
x := cx + (rx*ry*cosfi)/nom x := cx + (rx*ry*cosfi)/nom
y := cy + (rx*ry*sinfi)/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 // compute large and sweep flags
large := 0 large := 0
@ -144,6 +142,15 @@ func toSvgPathDesc(p *draw2d.Path) string { // TODO move elsewhere
if !math.Signbit(ps[5]) { if !math.Signbit(ps[5]) {
sweep = 1 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 // rx ry x-axis-rotation large-arc-flag sweep-flag x y
parts[i] = fmt.Sprintf("A %.4f %.4f %v %v %v %.4f %.4f", parts[i] = fmt.Sprintf("A %.4f %.4f %v %v %v %.4f %.4f",

View File

@ -8,8 +8,8 @@ import (
"log" "log"
"path/filepath" "path/filepath"
"sync"
"github.com/golang/freetype/truetype" "github.com/golang/freetype/truetype"
"sync"
) )
// FontStyle defines bold and italic styles for the font // FontStyle defines bold and italic styles for the font
@ -125,7 +125,7 @@ type FolderFontCache struct {
namer FontFileNamer namer FontFileNamer
} }
// NewFolderFontCache creates FolderFontCache // NewFolderFontCache creates FolderFontCache
func NewFolderFontCache(folder string) *FolderFontCache { func NewFolderFontCache(folder string) *FolderFontCache {
return &FolderFontCache{ return &FolderFontCache{
fonts: make(map[string]*truetype.Font), fonts: make(map[string]*truetype.Font),
@ -168,9 +168,7 @@ type SyncFolderFontCache struct {
namer FontFileNamer namer FontFileNamer
} }
// NewSyncFolderFontCache creates SyncFolderFontCache
// NewSyncFolderFontCache creates SyncFolderFontCache
func NewSyncFolderFontCache(folder string) *SyncFolderFontCache { func NewSyncFolderFontCache(folder string) *SyncFolderFontCache {
return &SyncFolderFontCache{ return &SyncFolderFontCache{
fonts: make(map[string]*truetype.Font), fonts: make(map[string]*truetype.Font),

View File

@ -2,7 +2,6 @@
package draw2d_test package draw2d_test
import ( import (
"fmt" "fmt"
"github.com/llgcode/draw2d" "github.com/llgcode/draw2d"