faster font contour path

This commit is contained in:
Thomas Friedel 2020-03-24 14:25:51 +01:00
parent c36395c0c8
commit a0a1cea270
2 changed files with 7 additions and 2 deletions

View file

@ -16,6 +16,8 @@ type Path2D struct {
standalone bool
fillCache []backendbase.Vec
noSelfIntersection bool
}
type pathPoint struct {
@ -104,9 +106,12 @@ func (p *Path2D) lineTo(x, y float64, checkSelfIntersection bool) {
}
}
csi := checkSelfIntersection && !Performance.IgnoreSelfIntersections && !p.noSelfIntersection
if prev.flags&pathSelfIntersects > 0 {
newp.flags |= pathSelfIntersects
} else if newp.flags&pathIsConvex == 0 && newp.flags&pathSelfIntersects == 0 && checkSelfIntersection && !Performance.IgnoreSelfIntersections {
} else if newp.flags&pathIsConvex == 0 && newp.flags&pathSelfIntersects == 0 && csi {
cuts := false
var cutPoint backendbase.Vec
b0, b1 := prev.pos, backendbase.Vec{x, y}

View file

@ -489,7 +489,7 @@ func (cv *Canvas) runePath(rn rune) *Path2D {
}
}
path := &Path2D{cv: cv, p: make([]pathPoint, 0, 50), standalone: true}
path := &Path2D{cv: cv, p: make([]pathPoint, 0, 50), standalone: true, noSelfIntersection: true}
const scale = 1.0 / 64.0