From f8712da1cfd3bfed39e9b303361d7d58390bb3f4 Mon Sep 17 00:00:00 2001 From: Jacob <2606873+unitoftime@users.noreply.github.com> Date: Sat, 26 Oct 2024 07:22:46 -0400 Subject: [PATCH] Add rect padding functions --- glm/rect.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/glm/rect.go b/glm/rect.go index d904410..a097daa 100644 --- a/glm/rect.go +++ b/glm/rect.go @@ -224,11 +224,21 @@ func (r Rect) Snap() Rect { return r } -// Adds padding to a rectangle consistently +// Adds padding to a rectangle consistently on every edge func (r Rect) PadAll(padding float64) Rect { return r.Pad(R(padding, padding, padding, padding)) } +// Adds padding to a rectangle on the X axis +func (r Rect) PadX(padding float64) Rect { + return r.Pad(R(padding, 0, padding, 0)) +} + +// Adds padding to a rectangle on the Y Axis +func (r Rect) PadY(padding float64) Rect { + return r.Pad(R(0, padding, 0, padding)) +} + // Adds padding to a rectangle (pads inward if padding is negative) func (r Rect) Pad(pad Rect) Rect { return R(r.Min.X-pad.Min.X, r.Min.Y-pad.Min.Y, r.Max.X+pad.Max.X, r.Max.Y+pad.Max.Y)