diff --git a/raygui/raygui.go b/raygui/raygui.go index 9ea0b17..4470a61 100644 --- a/raygui/raygui.go +++ b/raygui/raygui.go @@ -45,3 +45,24 @@ func GetInteractionState(rectangles ...rl.Rectangle) ControlState { return Focused } } + +// InsetRectangle returns the dimensions of a rectangle inset by a margin within an outer rectangle. +func InsetRectangle(outer rl.RectangleInt32, inset int32) rl.RectangleInt32 { + return rl.RectangleInt32{ + X: outer.X + inset, Y: outer.Y + inset, + Width: outer.Width - 2*inset, Height: outer.Height - 2*inset, + } +} + +// DrawInsetRectangle is a helper to draw a box inset by a margin of an outer container. +func DrawInsetRectangle(outer rl.RectangleInt32, inset int32, color rl.Color) { + inside := InsetRectangle(outer, inset) + rl.DrawRectangle(inside.X, inside.Y, inside.Width, inside.Height, color) +} + +// DrawBorderedRectangle is a helper to draw a box with a border around it. +func DrawBorderedRectangle(bounds rl.RectangleInt32, borderWidth int32, borderColor, insideColor rl.Color) { + inside := InsetRectangle(bounds, borderWidth) + rl.DrawRectangle(bounds.X, bounds.Y, bounds.Width, bounds.Height, borderColor) + rl.DrawRectangle(inside.X, inside.Y, inside.Width, inside.Height, insideColor) +}