Polygon boundary detection now rounds properly

This commit is contained in:
Sasha Koshka 2024-06-24 19:04:08 -04:00
parent 868b6fdfe9
commit 07865dc85f

View File

@ -1,6 +1,7 @@
package xcanvas
import "sort"
import "math"
import "image"
import "github.com/jezek/xgbutil/xgraphics"
@ -181,11 +182,11 @@ func (this *pen) fillPolygon (c xgraphics.BGRA, points ...image.Point) {
(fPointY < fy && fPrevY >= fy) ||
(fPrevY < fy && fPointY >= fy)
if addboundary {
context.boundaries[boundaryCount] = int (
context.boundaries[boundaryCount] = int(math.Round (
fPointX +
(fy - fPointY) /
(fPrevY - fPointY) *
(fPrevX - fPointX))
(fPrevX - fPointX)))
boundaryCount ++
}
prevPoint = point