Polygon boundary detection now rounds properly
This commit is contained in:
parent
868b6fdfe9
commit
07865dc85f
@ -1,6 +1,7 @@
|
|||||||
package xcanvas
|
package xcanvas
|
||||||
|
|
||||||
import "sort"
|
import "sort"
|
||||||
|
import "math"
|
||||||
import "image"
|
import "image"
|
||||||
import "github.com/jezek/xgbutil/xgraphics"
|
import "github.com/jezek/xgbutil/xgraphics"
|
||||||
|
|
||||||
@ -181,11 +182,11 @@ func (this *pen) fillPolygon (c xgraphics.BGRA, points ...image.Point) {
|
|||||||
(fPointY < fy && fPrevY >= fy) ||
|
(fPointY < fy && fPrevY >= fy) ||
|
||||||
(fPrevY < fy && fPointY >= fy)
|
(fPrevY < fy && fPointY >= fy)
|
||||||
if addboundary {
|
if addboundary {
|
||||||
context.boundaries[boundaryCount] = int (
|
context.boundaries[boundaryCount] = int(math.Round (
|
||||||
fPointX +
|
fPointX +
|
||||||
(fy - fPointY) /
|
(fy - fPointY) /
|
||||||
(fPrevY - fPointY) *
|
(fPrevY - fPointY) *
|
||||||
(fPrevX - fPointX))
|
(fPrevX - fPointX)))
|
||||||
boundaryCount ++
|
boundaryCount ++
|
||||||
}
|
}
|
||||||
prevPoint = point
|
prevPoint = point
|
||||||
|
Loading…
Reference in New Issue
Block a user