Fix centered texture rendering

This commit is contained in:
Sasha Koshka 2024-05-26 16:54:00 -04:00
parent 36ac66b644
commit 9214f70b61
1 changed files with 8 additions and 4 deletions

12
box.go
View File

@ -339,10 +339,14 @@ func (this *box) Draw (can canvas.Canvas) {
// centered texture
if this.textureMode == textureModeCenter {
textureBounds := this.texture.Bounds()
textureOrigin := image.Pt (
textureBounds.Dx() / -2,
textureBounds.Dy() / -2).
Add(bounds.Min)
textureOrigin :=
bounds.Min.
Add(image.Pt (
bounds.Dx() / 2,
bounds.Dy() / 2)).
Sub(image.Pt (
textureBounds.Dx() / 2,
textureBounds.Dy() / 2))
pen.Fill(color.Transparent)
pen.Texture(this.texture)