Polygon boundary detection now rounds properly
This commit is contained in:
parent
868b6fdfe9
commit
07865dc85f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user