Minor drawing fixess

This commit is contained in:
2023-09-08 16:39:58 -04:00
parent db2ed06daf
commit c91d4577e7
3 changed files with 13 additions and 4 deletions

View File

@@ -97,7 +97,7 @@ func (this *pen) Path (points ...image.Point) {
if this.fill.A > 0 {
this.fillPolygon(this.fill, points...)
}
} else if this.closed {
} else if this.closed && len(points) > 2 {
if this.stroke.A > 0 {
this.strokePolygon(this.stroke, points...)
}

View File

@@ -3,6 +3,7 @@ package xcanvas
import "image"
import "github.com/jezek/xgbutil/xgraphics"
// TODO: clip the line to the bounds
func (this *pen) line (
c xgraphics.BGRA,
min image.Point,
@@ -17,11 +18,11 @@ func (this *pen) line (
min: min,
max: max,
}
if abs(max.Y - min.Y) < abs(max.X - min.X) {
if max.X < min.X { context.swap() }
context.lineLow()
} else {
if max.Y < min.Y { context.swap() }
context.lineHigh()