more precise rasterization
This commit is contained in:
parent
973e410204
commit
4d0f41cc6b
1 changed files with 8 additions and 2 deletions
|
@ -19,10 +19,10 @@ func triangleLR(tri [][2]float64, y float64) (l, r float64, outside bool) {
|
|||
}
|
||||
|
||||
// check general bounds
|
||||
if y < a[1] {
|
||||
if y <= a[1] {
|
||||
return a[0], a[0], true
|
||||
}
|
||||
if y >= c[1] {
|
||||
if y > c[1] {
|
||||
return c[0], c[0], true
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,9 @@ func (b *SoftwareBackend) fillTriangle(tri [][2]float64, fn func(x, y int)) {
|
|||
} else if r > float64(b.w) {
|
||||
r = float64(b.w)
|
||||
}
|
||||
if l >= r {
|
||||
continue
|
||||
}
|
||||
fl, cr := int(math.Floor(l)), int(math.Ceil(r))
|
||||
for x := fl; x <= cr; x++ {
|
||||
fx := float64(x) + 0.5
|
||||
|
@ -127,6 +130,9 @@ func (b *SoftwareBackend) fillQuad(quad [4][2]float64, fn func(x, y int, sx, sy
|
|||
} else if r > float64(b.w) {
|
||||
r = float64(b.w)
|
||||
}
|
||||
if l >= r {
|
||||
continue
|
||||
}
|
||||
|
||||
v0 := [2]float64{float64(l) - quad[0][0], float64(y) - quad[0][1]}
|
||||
sx0 := topv[0]*v0[0] + topv[1]*v0[1]
|
||||
|
|
Loading…
Reference in a new issue