Added bordered-rectangle helper functions (without adding users)
This commit is contained in:
parent
eff176bb13
commit
0e83add8be
1 changed files with 21 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue