add background for F3 text, fix single-channel texture display
This commit is contained in:
@@ -21,6 +21,20 @@ func Text(format string, a ...interface{}) {
|
||||
imgui.Text(fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
// TextBackground wraps imgui.Text to create a
|
||||
// shortcut for fmt.Sprintf.
|
||||
//
|
||||
// It also fills the background of the text with the given color.
|
||||
func TextBackground(color itype.Vec4f, padding itype.Vec2f, format string, a ...interface{}) {
|
||||
text := fmt.Sprintf(format, a...)
|
||||
orig := imgui.CursorScreenPos()
|
||||
size := imgui.CalcTextSize(text, false, 0)
|
||||
halfpad := padding.Multiply(0.5)
|
||||
imgui.BackgroundDrawList().AddRectFilledV(orig.Minus(Vec2(halfpad)), orig.Plus(size).Plus(Vec2(halfpad)), PackedColor(color), 0, 0)
|
||||
|
||||
imgui.Text(text)
|
||||
}
|
||||
|
||||
// Begin wraps imgui.BeginV to create a
|
||||
// easy-to-use and intuitive interface.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user