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 {
return map[LineCap]string{
RoundCap: "round",
ButtCap: "cap",
RoundCap: "round",
ButtCap: "cap",
SquareCap: "square",
}[cap]
}

View file

@ -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",

View file

@ -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),

View file

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