From 9214f70b617f9239216746c34bdc7f0aa9a1110c Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 26 May 2024 16:54:00 -0400 Subject: [PATCH] Fix centered texture rendering --- box.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/box.go b/box.go index aa2dafb..b356aaf 100644 --- a/box.go +++ b/box.go @@ -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)