mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
vector: allow NonZero for AppendVerticesAndIndicesForStroke
Closes #2833
This commit is contained in:
parent
b6252a41f2
commit
230619a036
@ -140,12 +140,16 @@ func drawEbitenText(screen *ebiten.Image, x, y int, aa bool, line bool) {
|
||||
|
||||
op := &ebiten.DrawTrianglesOptions{}
|
||||
op.AntiAlias = aa
|
||||
if !line {
|
||||
// ebiten.EvenOdd is also fine here.
|
||||
// NonZero and EvenOdd differ when rendering a complex polygons with self-intersections and/or holes.
|
||||
// See https://en.wikipedia.org/wiki/Nonzero-rule and https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule .
|
||||
op.FillRule = ebiten.NonZero
|
||||
}
|
||||
|
||||
// For strokes (AppendVerticesAndIndicesForStroke), FillAll and NonZero work.
|
||||
//
|
||||
// For filling (AppendVerticesAndIndicesForFilling), NonZero and EvenOdd work.
|
||||
// NonZero and EvenOdd differ when rendering a complex polygons with self-intersections and/or holes.
|
||||
// See https://en.wikipedia.org/wiki/Nonzero-rule and https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule .
|
||||
//
|
||||
// For simplicity, this example always uses NonZero, whichever strokes or filling is done.
|
||||
op.FillRule = ebiten.NonZero
|
||||
|
||||
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
||||
}
|
||||
|
||||
@ -199,9 +203,7 @@ func drawEbitenLogo(screen *ebiten.Image, x, y int, aa bool, line bool) {
|
||||
|
||||
op := &ebiten.DrawTrianglesOptions{}
|
||||
op.AntiAlias = aa
|
||||
if !line {
|
||||
op.FillRule = ebiten.NonZero
|
||||
}
|
||||
op.FillRule = ebiten.NonZero
|
||||
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
||||
}
|
||||
|
||||
@ -243,9 +245,7 @@ func drawArc(screen *ebiten.Image, count int, aa bool, line bool) {
|
||||
|
||||
op := &ebiten.DrawTrianglesOptions{}
|
||||
op.AntiAlias = aa
|
||||
if !line {
|
||||
op.FillRule = ebiten.NonZero
|
||||
}
|
||||
op.FillRule = ebiten.NonZero
|
||||
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
||||
}
|
||||
|
||||
@ -300,9 +300,7 @@ func drawWave(screen *ebiten.Image, counter int, aa bool, line bool) {
|
||||
|
||||
op := &ebiten.DrawTrianglesOptions{}
|
||||
op.AntiAlias = aa
|
||||
if !line {
|
||||
op.FillRule = ebiten.NonZero
|
||||
}
|
||||
op.FillRule = ebiten.NonZero
|
||||
screen.DrawTriangles(vs, is, whiteSubImage, op)
|
||||
}
|
||||
|
||||
|
@ -480,7 +480,7 @@ type StrokeOptions struct {
|
||||
// The returned vertice's SrcX and SrcY are 0, and ColorR, ColorG, ColorB, and ColorA are 1.
|
||||
//
|
||||
// The returned values are intended to be passed to DrawTriangles or DrawTrianglesShader with a solid (non-transparent) color
|
||||
// with the FillAll fill rule (not NonZero or EvenOdd fill rule).
|
||||
// with FillAll or NonZero fill rule, not EvenOdd fill rule.
|
||||
func (p *Path) AppendVerticesAndIndicesForStroke(vertices []ebiten.Vertex, indices []uint16, op *StrokeOptions) ([]ebiten.Vertex, []uint16) {
|
||||
if op == nil {
|
||||
return vertices, indices
|
||||
@ -536,7 +536,8 @@ func (p *Path) AppendVerticesAndIndicesForStroke(vertices []ebiten.Vertex, indic
|
||||
ColorA: 1,
|
||||
})
|
||||
}
|
||||
indices = append(indices, idx, idx+1, idx+2, idx+1, idx+2, idx+3)
|
||||
// All the triangles are rendered in clockwise order to enable NonZero filling rule (#2833).
|
||||
indices = append(indices, idx, idx+1, idx+2, idx+1, idx+3, idx+2)
|
||||
|
||||
// Add line joints.
|
||||
var nextRect [4]point
|
||||
|
Loading…
Reference in New Issue
Block a user