go fmt
This commit is contained in:
parent
3e4c36c4c9
commit
8167230c09
4 changed files with 15 additions and 15 deletions
|
@ -4,8 +4,8 @@
|
|||
package draw2dbase
|
||||
|
||||
import (
|
||||
"math"
|
||||
"errors"
|
||||
"math"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -75,11 +75,11 @@ func TraceCubic(t Liner, cubic []float64, flatteningThreshold float64) error {
|
|||
// if it's flat then trace a line
|
||||
if (d2+d3)*(d2+d3) <= flatteningThreshold*(dx*dx+dy*dy) || i == len(curves)-8 {
|
||||
t.LineTo(c[6], c[7])
|
||||
i-=8
|
||||
i -= 8
|
||||
} else {
|
||||
// second half of bezier go lower onto the stack
|
||||
SubdivideCubic(c, curves[i+8:], curves[i:])
|
||||
i+=8
|
||||
i += 8
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -130,13 +130,13 @@ func TraceQuad(t Liner, quad []float64, flatteningThreshold float64) error {
|
|||
d = math.Abs(((c[2]-c[4])*dy - (c[3]-c[5])*dx))
|
||||
|
||||
// if it's flat then trace a line
|
||||
if (d*d) <= flatteningThreshold*(dx*dx+dy*dy) || i == len(curves) - 6 {
|
||||
if (d*d) <= flatteningThreshold*(dx*dx+dy*dy) || i == len(curves)-6 {
|
||||
t.LineTo(c[4], c[5])
|
||||
i-=6
|
||||
i -= 6
|
||||
} else {
|
||||
// second half of bezier go lower onto the stack
|
||||
SubdivideQuad(c, curves[i + 6:], curves[i:])
|
||||
i+=6
|
||||
SubdivideQuad(c, curves[i+6:], curves[i:])
|
||||
i += 6
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -126,7 +126,7 @@ type GraphicContext struct {
|
|||
fillRasterizer *raster.Rasterizer
|
||||
strokeRasterizer *raster.Rasterizer
|
||||
glyphBuf *truetype.GlyphBuf
|
||||
DPI int
|
||||
DPI int
|
||||
}
|
||||
|
||||
// NewGraphicContext creates a new Graphic context from an image.
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package draw2dimg
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"fmt"
|
||||
"testing"
|
||||
"github.com/golang/freetype/truetype"
|
||||
"github.com/llgcode/draw2d"
|
||||
"github.com/llgcode/draw2d/draw2dkit"
|
||||
"github.com/golang/freetype/truetype"
|
||||
"golang.org/x/image/font/gofont/goregular"
|
||||
"image"
|
||||
"image/color"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// font generated from icomoon.io and converted to go byte slice
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// go test -race -test.v sync_test.go
|
||||
// go test -race -test.v sync_test.go
|
||||
|
||||
package draw2d_test
|
||||
|
||||
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
func TestSync(t *testing.T) {
|
||||
ch := make(chan int)
|
||||
limit := 2000
|
||||
limit := 2
|
||||
for i := 0; i < limit; i++ {
|
||||
go Draw(i, ch)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func TestSync(t *testing.T) {
|
|||
}
|
||||
|
||||
func Draw(i int, ch chan<- int) {
|
||||
draw2d.SetFontFolder("./resource/font")
|
||||
draw2d.SetFontFolder("./resource/font")
|
||||
// Draw a rounded rectangle using default colors
|
||||
dest := image.NewRGBA(image.Rect(0, 0, 297, 210.0))
|
||||
gc := draw2dimg.NewGraphicContext(dest)
|
||||
|
|
Loading…
Reference in a new issue