#pragma once #define IMGUI_DEFINE_MATH_OPERATORS #include "imgui_internal.h" #include inline ImColor main_color(230, 134, 224, 255); inline ImColor text_color[3] = {ImColor(255, 255, 255, 255), ImColor(200, 200, 200, 255), ImColor(150, 150, 150, 255) }; inline ImColor foreground_color(1.f, 1.f, 1.f, 0.15f); inline ImColor background_color(13, 14, 16, 200); inline ImColor second_color(255, 255, 255, 20); inline ImColor stroke_color(35, 35, 35, 255); inline ImColor child_color(19, 19, 19, 255); inline ImColor scroll_bg_col(24, 24, 24, 255); inline ImColor winbg_color(15, 16, 18, 200); inline ImFont* icon_font; inline ImFont* logo_font; inline ImFont* icon_big_font; inline ImFont* medium_font; inline ImFont* small_font; inline ImFont* small_icon_font; inline ImFont* arrow_icons; inline ImVec2 frame_size(305, 46); inline float anim_speed = 8.f; static inline ImDrawList* foremenu_drawlist; inline ImColor GetDarkColor(const ImColor& color) { // Получите значения каналов цвета из входного цвета. float r, g, b, a; r = color.Value.x; g = color.Value.y; b = color.Value.z; a = 255; // Примените логику для получения "темного" цвета. // Здесь я использую некоторую процентную смесь текущего цвета с черным цветом, // чтобы сделать его более темным. Вы можете настроить эту логику по вашему усмотрению. float darkPercentage = 0.4f; // Процент темноты (от 0.0 до 1.0). float darkR = r * darkPercentage; float darkG = g * darkPercentage; float darkB = b * darkPercentage; // Создайте и верните темный цвет. return ImColor(darkR, darkG, darkB, a); } inline float ImDegToRad(float degrees) { static const float deg_to_rad = 0.01745329251994329576923690768489f; return degrees * deg_to_rad; } inline ImColor GetColorWithAlpha(ImColor color, float alpha) { return ImColor(color.Value.x, color.Value.y, color.Value.z, alpha); } inline ImVec2 center_text(ImVec2 min, ImVec2 max, const char* text) { return min + (max - min) / 2 - ImGui::CalcTextSize(text) / 2; } inline int rotation_start_index; inline void ImRotateStart() { rotation_start_index = ImGui::GetWindowDrawList()->VtxBuffer.Size; } inline ImVec2 ImRotationCenter() { ImVec2 l(FLT_MAX, FLT_MAX), u(-FLT_MAX, -FLT_MAX); // bounds const auto& buf = ImGui::GetWindowDrawList()->VtxBuffer; for (int i = rotation_start_index; i < buf.Size; i++) l = ImMin(l, buf[i].pos), u = ImMax(u, buf[i].pos); return ImVec2((l.x + u.x) / 2, (l.y + u.y) / 2); // or use _ClipRectStack? } inline ImVec4 ImColorToImVec4(const ImColor& color) { return ImVec4(color.Value.x, color.Value.y, color.Value.z, color.Value.w); } inline void Pickerbox(std::string label, bool* v, float col[4]) { std::string picker_name = "##picker" + label; frame_size = ImVec2(235, 46); ImGui::Checkbox(label.c_str(), v); ImGui::SameLine(); frame_size = ImVec2(60, 46); ImGui::ColorEdit4(picker_name.c_str(), (float*)col, ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_PickerHueBar | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoAlpha, true); frame_size = ImVec2(305, 46); } inline void Keybindbox(std::string label, bool* v, int* key) { std::string picker_name = "##keybind" + label; frame_size = ImVec2(235, 46); ImGui::Checkbox(label.c_str(), v); ImGui::SameLine(); frame_size = ImVec2(60, 46); ImGui::Keybind(picker_name.c_str(), key); frame_size = ImVec2(305, 46); } inline void ImRotateEnd(float rad, ImVec2 center = ImRotationCenter()) { float s = sin(rad), c = cos(rad); center = ImRotate(center, s, c) - center; auto& buf = ImGui::GetWindowDrawList()->VtxBuffer; for (int i = rotation_start_index; i < buf.Size; i++) buf[i].pos = ImRotate(buf[i].pos, s, c) - center; } inline void rect_glow(ImDrawList* draw, ImVec2 start, ImVec2 end, ImColor col, float rounding, float intensity) { while (true) { if (col.Value.w < 0.0019f) break; draw->AddRectFilled(start, end, col, rounding); col.Value.w -= col.Value.w / intensity; start = ImVec2(start.x - 1, start.y - 1); end = ImVec2(end.x + 1, end.y + 1); } } inline void ShadeVertsLinearColorGradientSetAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1) { ImVec2 gradient_extent = gradient_p1 - gradient_p0; float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent); ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx; ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx; const int col0_r = (int)(col0 >> IM_COL32_R_SHIFT) & 0xFF; const int col0_g = (int)(col0 >> IM_COL32_G_SHIFT) & 0xFF; const int col0_b = (int)(col0 >> IM_COL32_B_SHIFT) & 0xFF; const int col0_a = (int)(col0 >> IM_COL32_A_SHIFT) & 0xFF; const int col_delta_r = ((int)(col1 >> IM_COL32_R_SHIFT) & 0xFF) - col0_r; const int col_delta_g = ((int)(col1 >> IM_COL32_G_SHIFT) & 0xFF) - col0_g; const int col_delta_b = ((int)(col1 >> IM_COL32_B_SHIFT) & 0xFF) - col0_b; const int col_delta_a = ((int)(col1 >> IM_COL32_A_SHIFT) & 0xFF) - col0_a; for (ImDrawVert* vert = vert_start; vert < vert_end; vert++) { float d = ImDot(vert->pos - gradient_p0, gradient_extent); float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f); int r = (int)(col0_r + col_delta_r * t); int g = (int)(col0_g + col_delta_g * t); int b = (int)(col0_b + col_delta_b * t); int a = (int)(col0_a + col_delta_a * t); vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (a << IM_COL32_A_SHIFT); } }