From 8167230c09f82e695209ee6072232fa5b4b6878e Mon Sep 17 00:00:00 2001 From: llgcode Date: Mon, 4 Dec 2017 09:46:40 +0100 Subject: [PATCH] go fmt --- draw2dbase/curve.go | 14 +++++++------- draw2dgl/gc.go | 2 +- draw2dimg/curve_limit_test.go | 8 ++++---- sync_test.go | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/draw2dbase/curve.go b/draw2dbase/curve.go index ca128ac..05a9ede 100644 --- a/draw2dbase/curve.go +++ b/draw2dbase/curve.go @@ -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 diff --git a/draw2dgl/gc.go b/draw2dgl/gc.go index d512ccc..2e0a99f 100644 --- a/draw2dgl/gc.go +++ b/draw2dgl/gc.go @@ -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. diff --git a/draw2dimg/curve_limit_test.go b/draw2dimg/curve_limit_test.go index a281f88..26ecdb0 100644 --- a/draw2dimg/curve_limit_test.go +++ b/draw2dimg/curve_limit_test.go @@ -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 diff --git a/sync_test.go b/sync_test.go index 76d5aed..8580a81 100644 --- a/sync_test.go +++ b/sync_test.go @@ -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)