Fix boundary detection for polygons
This commit is contained in:
parent
07865dc85f
commit
39a591e732
@ -159,12 +159,12 @@ func (this *pen) fillPolygon (c xgraphics.BGRA, points ...image.Point) {
|
|||||||
area = this.image.Bounds().Intersect(area)
|
area = this.image.Bounds().Intersect(area)
|
||||||
if area.Empty() { return }
|
if area.Empty() { return }
|
||||||
|
|
||||||
|
boundaries := make([]int, len(points))
|
||||||
context := fillingContext {
|
context := fillingContext {
|
||||||
image: this.image,
|
image: this.image,
|
||||||
color: this.fill,
|
color: this.fill,
|
||||||
min: area.Min.X,
|
min: area.Min.X,
|
||||||
max: area.Max.X,
|
max: area.Max.X,
|
||||||
boundaries: make([]int, len(points)),
|
|
||||||
points: points,
|
points: points,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ 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(math.Round (
|
boundaries[boundaryCount] = int(math.Round (
|
||||||
fPointX +
|
fPointX +
|
||||||
(fy - fPointY) /
|
(fy - fPointY) /
|
||||||
(fPrevY - fPointY) *
|
(fPrevY - fPointY) *
|
||||||
@ -193,8 +193,8 @@ func (this *pen) fillPolygon (c xgraphics.BGRA, points ...image.Point) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sort boundary list
|
// sort boundary list
|
||||||
cutBoundaries := context.boundaries[:boundaryCount]
|
context.boundaries = boundaries[:boundaryCount]
|
||||||
sort.Ints(cutBoundaries)
|
sort.Ints(context.boundaries)
|
||||||
|
|
||||||
// fill pixels between boundary pairs
|
// fill pixels between boundary pairs
|
||||||
if c.A == 255 {
|
if c.A == 255 {
|
||||||
|
Loading…
Reference in New Issue
Block a user