imgui.text

Vespan

loneliness
Автор темы
Проверенный
2,140
1,793
Версия MoonLoader
.026-beta
как выровнить imgui.Text по центру imgui.BeginChild ?
 
Решение
как выровнить imgui.Text по центру imgui.BeginChild ?
Lua:
-- Imgui
imgui.CenterText('Text')
--
function imgui.CenterText(text, color)
    color = color or imgui.GetStyle().Colors[imgui.Col.Text]
    local width = imgui.GetWindowWidth()
    for line in text:gmatch('[^\n]+') do
        local lenght = imgui.CalcTextSize(line).x
        imgui.SetCursorPosX((width - lenght) / 2)
        imgui.TextColored(color, line)
    end
end

Rice.

Известный
Модератор
1,753
1,660
как выровнить imgui.Text по центру imgui.BeginChild ?
Lua:
-- Imgui
imgui.CenterText('Text')
--
function imgui.CenterText(text, color)
    color = color or imgui.GetStyle().Colors[imgui.Col.Text]
    local width = imgui.GetWindowWidth()
    for line in text:gmatch('[^\n]+') do
        local lenght = imgui.CalcTextSize(line).x
        imgui.SetCursorPosX((width - lenght) / 2)
        imgui.TextColored(color, line)
    end
end