Compare commits
2 Commits
868b6fdfe9
...
v0.4.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 39a591e732 | |||
| 07865dc85f |
@@ -1,6 +1,7 @@
|
||||
package xcanvas
|
||||
|
||||
import "sort"
|
||||
import "math"
|
||||
import "image"
|
||||
import "github.com/jezek/xgbutil/xgraphics"
|
||||
|
||||
@@ -158,12 +159,12 @@ func (this *pen) fillPolygon (c xgraphics.BGRA, points ...image.Point) {
|
||||
area = this.image.Bounds().Intersect(area)
|
||||
if area.Empty() { return }
|
||||
|
||||
boundaries := make([]int, len(points))
|
||||
context := fillingContext {
|
||||
image: this.image,
|
||||
color: this.fill,
|
||||
min: area.Min.X,
|
||||
max: area.Max.X,
|
||||
boundaries: make([]int, len(points)),
|
||||
points: points,
|
||||
}
|
||||
|
||||
@@ -181,19 +182,19 @@ func (this *pen) fillPolygon (c xgraphics.BGRA, points ...image.Point) {
|
||||
(fPointY < fy && fPrevY >= fy) ||
|
||||
(fPrevY < fy && fPointY >= fy)
|
||||
if addboundary {
|
||||
context.boundaries[boundaryCount] = int (
|
||||
boundaries[boundaryCount] = int(math.Round (
|
||||
fPointX +
|
||||
(fy - fPointY) /
|
||||
(fPrevY - fPointY) *
|
||||
(fPrevX - fPointX))
|
||||
(fPrevX - fPointX)))
|
||||
boundaryCount ++
|
||||
}
|
||||
prevPoint = point
|
||||
}
|
||||
|
||||
// sort boundary list
|
||||
cutBoundaries := context.boundaries[:boundaryCount]
|
||||
sort.Ints(cutBoundaries)
|
||||
context.boundaries = boundaries[:boundaryCount]
|
||||
sort.Ints(context.boundaries)
|
||||
|
||||
// fill pixels between boundary pairs
|
||||
if c.A == 255 {
|
||||
|
||||
Reference in New Issue
Block a user