Minor drawing fixess
This commit is contained in:
parent
db2ed06daf
commit
c91d4577e7
@ -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...)
|
||||
}
|
||||
|
@ -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()
|
||||
|
10
canvasbox.go
10
canvasbox.go
@ -5,11 +5,13 @@ import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
|
||||
type canvasBox struct {
|
||||
*box
|
||||
userDrawer canvas.Drawer
|
||||
}
|
||||
|
||||
func (backend *Backend) NewCanvasBox () tomo.CanvasBox {
|
||||
this := &canvasBox { }
|
||||
this.box = backend.newBox(this)
|
||||
this.drawer = this
|
||||
return this
|
||||
}
|
||||
|
||||
@ -18,10 +20,16 @@ func (this *canvasBox) Box () tomo.Box {
|
||||
}
|
||||
|
||||
func (this *canvasBox) SetDrawer (drawer canvas.Drawer) {
|
||||
this.drawer = drawer
|
||||
this.userDrawer = drawer
|
||||
this.invalidateDraw()
|
||||
}
|
||||
|
||||
func (this *canvasBox) Invalidate () {
|
||||
this.invalidateDraw()
|
||||
}
|
||||
|
||||
func (this *canvasBox) Draw (can canvas.Canvas) {
|
||||
this.box.Draw(can)
|
||||
this.userDrawer.Draw (
|
||||
can.Clip(this.padding.Apply(this.innerClippingBounds)))
|
||||
}
|
||||
|
Reference in New Issue
Block a user