This commit is contained in:
llgcode 2017-12-04 09:46:40 +01:00
parent 3e4c36c4c9
commit 8167230c09
4 changed files with 15 additions and 15 deletions

View file

@ -4,8 +4,8 @@
package draw2dbase package draw2dbase
import ( import (
"math"
"errors" "errors"
"math"
) )
const ( const (
@ -75,11 +75,11 @@ func TraceCubic(t Liner, cubic []float64, flatteningThreshold float64) error {
// if it's flat then trace a line // if it's flat then trace a line
if (d2+d3)*(d2+d3) <= flatteningThreshold*(dx*dx+dy*dy) || i == len(curves)-8 { if (d2+d3)*(d2+d3) <= flatteningThreshold*(dx*dx+dy*dy) || i == len(curves)-8 {
t.LineTo(c[6], c[7]) t.LineTo(c[6], c[7])
i-=8 i -= 8
} else { } else {
// second half of bezier go lower onto the stack // second half of bezier go lower onto the stack
SubdivideCubic(c, curves[i+8:], curves[i:]) SubdivideCubic(c, curves[i+8:], curves[i:])
i+=8 i += 8
} }
} }
return nil 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)) d = math.Abs(((c[2]-c[4])*dy - (c[3]-c[5])*dx))
// if it's flat then trace a line // 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]) t.LineTo(c[4], c[5])
i-=6 i -= 6
} else { } else {
// second half of bezier go lower onto the stack // second half of bezier go lower onto the stack
SubdivideQuad(c, curves[i + 6:], curves[i:]) SubdivideQuad(c, curves[i+6:], curves[i:])
i+=6 i += 6
} }
} }
return nil return nil

View file

@ -1,14 +1,14 @@
package draw2dimg package draw2dimg
import ( import (
"image"
"image/color"
"fmt" "fmt"
"testing" "github.com/golang/freetype/truetype"
"github.com/llgcode/draw2d" "github.com/llgcode/draw2d"
"github.com/llgcode/draw2d/draw2dkit" "github.com/llgcode/draw2d/draw2dkit"
"github.com/golang/freetype/truetype"
"golang.org/x/image/font/gofont/goregular" "golang.org/x/image/font/gofont/goregular"
"image"
"image/color"
"testing"
) )
// font generated from icomoon.io and converted to go byte slice // font generated from icomoon.io and converted to go byte slice

View file

@ -13,7 +13,7 @@ import (
func TestSync(t *testing.T) { func TestSync(t *testing.T) {
ch := make(chan int) ch := make(chan int)
limit := 2000 limit := 2
for i := 0; i < limit; i++ { for i := 0; i < limit; i++ {
go Draw(i, ch) go Draw(i, ch)
} }