Исходник Imgui glow text

  • Автор темы Автор темы sky1e
  • Дата начала Дата начала
Участник
Участник
Статус
Оффлайн
Регистрация
19 Апр 2020
Сообщения
1,224
Реакции
317
C++:
Expand Collapse Copy
void RenderGlowingText(const char* text, const ImVec4& color, float glowSize, ImGuiWindow* window = nullptr) {
    ImGuiContext& g = *GImGui;
    ImGuiWindow* currentWindow = window ? window : g.CurrentWindow;

    ImVec2 pos = ImGui::GetCursorScreenPos();
    ImGui::RenderText(pos, text);

    ImDrawList* drawList = currentWindow->DrawList;
    ImVec2 textSize = ImGui::CalcTextSize(text);
    ImVec2 drawPos = pos;

    // Рендеринг обводки (глоу)
    drawList->AddText(drawPos, ImGui::ColorConvertFloat4ToU32(color), text);
    for (float i = 0; i < 360; i += 45) {
        float dx = cosf(i) * glowSize;
        float dy = sinf(i) * glowSize;
        drawList->AddText(drawPos + ImVec2(dx, dy), IM_COL32_BLACK_TRANS, text);
    }
}
 
C++:
Expand Collapse Copy
void RenderGlowingText(const char* text, const ImVec4& color, float glowSize, ImGuiWindow* window = nullptr) {
    ImGuiContext& g = *GImGui;
    ImGuiWindow* currentWindow = window ? window : g.CurrentWindow;

    ImVec2 pos = ImGui::GetCursorScreenPos();
    ImGui::RenderText(pos, text);

    ImDrawList* drawList = currentWindow->DrawList;
    ImVec2 textSize = ImGui::CalcTextSize(text);
    ImVec2 drawPos = pos;

    // Рендеринг обводки (глоу)
    drawList->AddText(drawPos, ImGui::ColorConvertFloat4ToU32(color), text);
    for (float i = 0; i < 360; i += 45) {
        float dx = cosf(i) * glowSize;
        float dy = sinf(i) * glowSize;
        drawList->AddText(drawPos + ImVec2(dx, dy), IM_COL32_BLACK_TRANS, text);
    }
}
ss?
 
C++:
Expand Collapse Copy
void RenderGlowingText(const char* text, const ImVec4& color, float glowSize, ImGuiWindow* window = nullptr) {
    ImGuiContext& g = *GImGui;
    ImGuiWindow* currentWindow = window ? window : g.CurrentWindow;

    ImVec2 pos = ImGui::GetCursorScreenPos();
    ImGui::RenderText(pos, text);

    ImDrawList* drawList = currentWindow->DrawList;
    ImVec2 textSize = ImGui::CalcTextSize(text);
    ImVec2 drawPos = pos;

    // Рендеринг обводки (глоу)
    drawList->AddText(drawPos, ImGui::ColorConvertFloat4ToU32(color), text);
    for (float i = 0; i < 360; i += 45) {
        float dx = cosf(i) * glowSize;
        float dy = sinf(i) * glowSize;
        drawList->AddText(drawPos + ImVec2(dx, dy), IM_COL32_BLACK_TRANS, text);
    }
}
1703264052563.png

OPTIMISATION V KOMPLEKTE
 
C++:
Expand Collapse Copy
void RenderGlowingText(const char* text, const ImVec4& color, float glowSize, ImGuiWindow* window = nullptr) {
    ImGuiContext& g = *GImGui;
    ImGuiWindow* currentWindow = window ? window : g.CurrentWindow;

    ImVec2 pos = ImGui::GetCursorScreenPos();
    ImGui::RenderText(pos, text);

    ImDrawList* drawList = currentWindow->DrawList;
    ImVec2 textSize = ImGui::CalcTextSize(text);
    ImVec2 drawPos = pos;

    // Рендеринг обводки (глоу)
    drawList->AddText(drawPos, ImGui::ColorConvertFloat4ToU32(color), text);
    for (float i = 0; i < 360; i += 45) {
        float dx = cosf(i) * glowSize;
        float dy = sinf(i) * glowSize;
        drawList->AddText(drawPos + ImVec2(dx, dy), IM_COL32_BLACK_TRANS, text);
    }
}
мне кажется полноценное меню с таким текстом ахуеет от оптимизации
 
so basically
C++:
Expand Collapse Copy
// Function to render glowing text
void RenderGlowingText(const char* text, ImVec4 color, ImVec4 glowColor, float glowSize) {
    // Get the current ImGui window draw list
    ImDrawList* drawList = ImGui::GetWindowDrawList();

    // Get the text size
    ImVec2 textSize = ImGui::CalcTextSize(text);

    // Calculate the position for the text
    ImVec2 textPos = ImGui::GetCursorScreenPos();

    // Render the glowing part of the text
    drawList->AddText(textPos, ImGui::ColorConvertFloat4ToU32(glowColor), text);
    drawList->AddText(textPos, ImGui::ColorConvertFloat4ToU32(glowColor), text, false, 0, glowSize);

    // Render the main text
    drawList->AddText(textPos, ImGui::ColorConvertFloat4ToU32(color), text);
}

but worse
 
  • Мне нравится
Реакции: mj12
C++:
Expand Collapse Copy
void RenderGlowingText(const char* text, const ImVec4& color, float glowSize, ImGuiWindow* window = nullptr) {
    ImGuiContext& g = *GImGui;
    ImGuiWindow* currentWindow = window ? window : g.CurrentWindow;

    ImVec2 pos = ImGui::GetCursorScreenPos();
    ImGui::RenderText(pos, text);

    ImDrawList* drawList = currentWindow->DrawList;
    ImVec2 textSize = ImGui::CalcTextSize(text);
    ImVec2 drawPos = pos;

    // Рендеринг обводки (глоу)
    drawList->AddText(drawPos, ImGui::ColorConvertFloat4ToU32(color), text);
    for (float i = 0; i < 360; i += 45) {
        float dx = cosf(i) * glowSize;
        float dy = sinf(i) * glowSize;
        drawList->AddText(drawPos + ImVec2(dx, dy), IM_COL32_BLACK_TRANS, text);
    }
}
не ворк
 
Назад
Сверху Снизу