├── ImCandy ├── candy.h └── gradient.h ├── LICENSE └── README.md /ImCandy/candy.h: -------------------------------------------------------------------------------- 1 | /* 2 | https://github.com/Raais/ImguiCandy 3 | 4 | MIT License 5 | 6 | Copyright (c) 2021 Raais N. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | #pragma once 27 | 28 | #include 29 | #include 30 | #include "imgui.h" 31 | #include "gradient.h" 32 | 33 | #ifdef IMCANDYCONSTS 34 | //Hex to ImVec4 helper: https://heximv4.rs5709.repl.co 35 | const ImVec4 IV4_WHITE{1.000,1.000,1.000,1.000};//#ffffff 36 | const ImVec4 IV4_BLACK{0.000,0.000,0.000,1.000};//#000000 37 | const ImVec4 IV4_CRIMSON{0.827,0.063,0.153,1.000};//#D31027 38 | const ImVec4 IV4_SKYBLUE{0.125,0.741,1.000,1.000};//#20BDFF 39 | const ImVec4 IV4_AZURE{0.000,0.447,1.000,1.000};//#0072ff 40 | const ImVec4 IV4_HOTPINK{1.000,0.000,0.600,1.000};//#FF0099 41 | const ImVec4 IV4_CHARTREUSE{0.678,0.820,0.000,1.000};//#ADD100 42 | const ImVec4 IV4_EMERALD{0.220,0.937,0.490,1.000};//#38ef7d 43 | const ImVec4 IV4_BUBBLEGUM{0.988,0.404,0.980,1.000};//#fc67fa 44 | const ImVec4 IV4_TWITCH{0.569,0.275,1.000,1.000};//#9146FF 45 | const ImVec4 IV4_DISCORD{0.345,0.396,0.949,1.000};//#5865F2 46 | const ImVec4 IV4_TWITTER{0.114,0.631,0.949,1.000};//#1DA1F2 47 | const ImVec4 IV4_SPOTIFY{0.114,0.725,0.329,1.000};//#1DB954 48 | const ImVec4 IV4_GOOGLEBLUE{0.259,0.522,0.957,1.000};//#4285F4 49 | const ImVec4 IV4_MANGO{1.000,0.784,0.216,1.000};//#FFC837 50 | const ImVec4 IV4_VIOLET{0.584,0.000,1.000,1.000};//#9500ff 51 | const ImVec4 IV4_COSMICLATTE{1.000,0.973,0.906,1.000};//#fff8e7 52 | const ImVec4 IV4_TEAL{0.314,0.788,0.765,1.000};//#50C9C3 53 | const ImVec4 IV4_DRACULA{0.157,0.165,0.212,1.000};//#282a36 54 | const ImVec4 IV4_2077YELLOW{0.992,0.961,0.000,1.000};//#fdf500 55 | const ImVec4 IV4_CPNBLUE{0.000,0.878,1.000,1.0000};//#00e0ff 56 | const ImVec4 IV4_CPNVIOLET{0.612,0.000,1.000,1.000};//#9c00ff 57 | const ImVec4 IV4_CPNPURPLE{0.365,0.000,1.000,1.000};//#5d00ff 58 | const ImVec4 IV4_CPNDEEP{0.000,0.039,0.122,1.000};//#000a1f 59 | #endif 60 | 61 | namespace ImCandy 62 | { 63 | /* 64 | These functions are to be used inside a loop, hence the use of static variables. 65 | Example usage: 66 | --------------------------------------------------------------- 67 | static double s0 = 0.0; 68 | ImGui::PushStyleColor(ImGuiCol_Border, ImCandy::Rainbow(s0)); 69 | --------------------------------------------------------------- 70 | 71 | ImVec4 Rainbow(double &static_ratio, double step = 0.01); 72 | 73 | ImVec4 RainbowP(double step = 0.01); 74 | 75 | ImVec4 Gradient2(ImVec4 col1, ImVec4 col2, double &static_ratio, double step = 0.01); 76 | 77 | ImVec4 Gradient3(ImVec4 col1, ImVec4 col2, ImVec4 col3, double &static_ratio, double step = 0.01); 78 | */ 79 | 80 | // WARNING: High step values can cause unpleasant flashes 81 | ImVec4 Rainbow(double &static_ratio, double step = 0.01) 82 | { 83 | step *= 6; //just to be linear with RainbowP 84 | 85 | gradient::LinearColorGradient gradient; 86 | gradient[0.0] = {255,0,0}; 87 | gradient[1.0] = {255,255,0}; 88 | gradient[2.0] = {0,255,0}; 89 | gradient[3.0] = {0,255,255}; 90 | gradient[4.0] = {0,0,255}; 91 | gradient[5.0] = {255,0,255}; 92 | gradient[6.0] = {255,0,0}; 93 | 94 | double r, g, b = 0; 95 | 96 | auto color = gradient(static_ratio); 97 | r = color[0]; 98 | g = color[1]; 99 | b = color[2]; 100 | 101 | static_ratio += step; 102 | if (static_ratio >= 6.0) 103 | static_ratio = 0.0; 104 | 105 | return ImVec4(r / 255.0, g / 255.0, b / 255.0, 1.0); 106 | } 107 | 108 | // Portable version 109 | ImVec4 RainbowP(double step = 0.01) 110 | { 111 | static double static_ratio = 0.0; 112 | 113 | int normalized = int(static_ratio * 256 * 6); 114 | 115 | int region = normalized / 256; 116 | 117 | int x = normalized % 256; 118 | 119 | int r = 0, g = 0, b = 0; 120 | switch (region) 121 | { 122 | case 0: r = 255; g = 0; b = 0; g += x; break; 123 | case 1: r = 255; g = 255; b = 0; r -= x; break; 124 | case 2: r = 0; g = 255; b = 0; b += x; break; 125 | case 3: r = 0; g = 255; b = 255; g -= x; break; 126 | case 4: r = 0; g = 0; b = 255; r += x; break; 127 | case 5: r = 255; g = 0; b = 255; b -= x; break; 128 | } 129 | 130 | static_ratio += step; 131 | if (static_ratio >= 1.0) 132 | static_ratio = 0.0; 133 | 134 | return ImVec4(r / 255.0, g / 255.0, b / 255.0, 1.0); 135 | } 136 | 137 | // Find some cool gradients from uigradients.com 138 | ImVec4 Gradient2(ImVec4 col1, ImVec4 col2, double &static_ratio, double step = 0.01) 139 | { 140 | std::valarray col1a(3); 141 | col1a[0] = col1.x * 255.0; 142 | col1a[1] = col1.y * 255.0; 143 | col1a[2] = col1.z * 255.0; 144 | std::valarray col2a(3); 145 | col2a[0] = col2.x * 255.0; 146 | col2a[1] = col2.y * 255.0; 147 | col2a[2] = col2.z * 255.0; 148 | 149 | gradient::LinearColorGradient gradient; 150 | gradient[0.0] = col1a; 151 | gradient[1.0] = col2a; 152 | gradient[2.0] = col1a; 153 | 154 | double r, g, b = 0; 155 | 156 | auto color = gradient(static_ratio); 157 | r = color[0]; 158 | g = color[1]; 159 | b = color[2]; 160 | 161 | static_ratio += step; 162 | if (static_ratio >= 2.0) 163 | static_ratio = 0.0; 164 | 165 | return ImVec4(r / 255.0, g / 255.0, b / 255.0, 1.0); 166 | } 167 | 168 | // Find some cool gradients from uigradients.com 169 | ImVec4 Gradient3(ImVec4 col1, ImVec4 col2, ImVec4 col3, double &static_ratio, double step = 0.01) 170 | { 171 | std::valarray col1a(3); 172 | col1a[0] = col1.x * 255.0; 173 | col1a[1] = col1.y * 255.0; 174 | col1a[2] = col1.z * 255.0; 175 | std::valarray col2a(3); 176 | col2a[0] = col2.x * 255.0; 177 | col2a[1] = col2.y * 255.0; 178 | col2a[2] = col2.z * 255.0; 179 | std::valarray col3a(3); 180 | col3a[0] = col3.x * 255.0; 181 | col3a[1] = col3.y * 255.0; 182 | col3a[2] = col3.z * 255.0; 183 | 184 | 185 | gradient::LinearColorGradient gradient; 186 | gradient[0.0] = col1a; 187 | gradient[1.0] = col2a; 188 | gradient[2.0] = col3a; 189 | gradient[3.0] = col1a; 190 | 191 | double r, g, b = 0; 192 | 193 | auto color = gradient(static_ratio); 194 | r = color[0]; 195 | g = color[1]; 196 | b = color[2]; 197 | 198 | static_ratio += step; 199 | if (static_ratio >= 3.0) 200 | static_ratio = 0.0; 201 | 202 | return ImVec4(r / 255.0, g / 255.0, b / 255.0, 1.0); 203 | } 204 | 205 | /*--------------------------------------------------------------------------------------------------------- 206 | THEMES */ 207 | 208 | void Theme_Blender(ImGuiStyle* dst = NULL) 209 | { 210 | // 'Blender Dark' theme from v3.0.0 [Improvised] 211 | // Colors grabbed using X11 Soft/xcolor 212 | ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); 213 | ImVec4* colors = style->Colors; 214 | ImGui::StyleColorsDark(style);//Reset to base/dark theme 215 | colors[ImGuiCol_Text] = ImVec4(0.84f, 0.84f, 0.84f, 1.00f); 216 | colors[ImGuiCol_WindowBg] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f); 217 | colors[ImGuiCol_ChildBg] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f); 218 | colors[ImGuiCol_PopupBg] = ImVec4(0.09f, 0.09f, 0.09f, 1.00f); 219 | colors[ImGuiCol_Border] = ImVec4(0.17f, 0.17f, 0.17f, 1.00f); 220 | colors[ImGuiCol_BorderShadow] = ImVec4(0.10f, 0.10f, 0.10f, 0.00f); 221 | colors[ImGuiCol_FrameBg] = ImVec4(0.33f, 0.33f, 0.33f, 1.00f); 222 | colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.47f, 1.00f); 223 | colors[ImGuiCol_FrameBgActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); 224 | colors[ImGuiCol_TitleBg] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); 225 | colors[ImGuiCol_TitleBgActive] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 226 | colors[ImGuiCol_MenuBarBg] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); 227 | colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.33f, 0.33f, 0.33f, 1.00f); 228 | colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.33f, 0.33f, 0.33f, 1.00f); 229 | colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.35f, 0.35f, 0.35f, 1.00f); 230 | colors[ImGuiCol_CheckMark] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 231 | colors[ImGuiCol_SliderGrab] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 232 | colors[ImGuiCol_SliderGrabActive] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 233 | colors[ImGuiCol_Button] = ImVec4(0.33f, 0.33f, 0.33f, 1.00f); 234 | colors[ImGuiCol_ButtonHovered] = ImVec4(0.40f, 0.40f, 0.40f, 1.00f); 235 | colors[ImGuiCol_ButtonActive] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 236 | colors[ImGuiCol_Header] = ImVec4(0.27f, 0.27f, 0.27f, 1.00f); 237 | colors[ImGuiCol_HeaderHovered] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 238 | colors[ImGuiCol_HeaderActive] = ImVec4(0.27f, 0.27f, 0.27f, 1.00f); 239 | colors[ImGuiCol_Separator] = ImVec4(0.18f, 0.18f, 0.18f, 1.00f); 240 | colors[ImGuiCol_SeparatorHovered] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 241 | colors[ImGuiCol_SeparatorActive] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 242 | colors[ImGuiCol_ResizeGrip] = ImVec4(0.54f, 0.54f, 0.54f, 1.00f); 243 | colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 244 | colors[ImGuiCol_ResizeGripActive] = ImVec4(0.19f, 0.39f, 0.69f, 1.00f); 245 | colors[ImGuiCol_Tab] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); 246 | colors[ImGuiCol_TabHovered] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); 247 | colors[ImGuiCol_TabActive] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f); 248 | colors[ImGuiCol_PlotHistogram] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 249 | colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.20f, 0.39f, 0.69f, 1.00f); 250 | colors[ImGuiCol_TextSelectedBg] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 251 | colors[ImGuiCol_NavHighlight] = ImVec4(0.28f, 0.45f, 0.70f, 1.00f); 252 | style->WindowPadding = ImVec2(12.00f, 8.00f); 253 | style->ItemSpacing = ImVec2(7.00f, 3.00f); 254 | style->GrabMinSize = 20.00f; 255 | style->WindowRounding = 8.00f; 256 | style->FrameBorderSize = 0.00f; 257 | style->FrameRounding = 4.00f; 258 | style->GrabRounding = 12.00f; 259 | } 260 | 261 | void Theme_Cyberpunk(ImGuiStyle* dst = NULL) 262 | { 263 | // Cyberpunk Neon [Improvised] 264 | // https://github.com/Roboron3042/Cyberpunk-Neon 265 | ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); 266 | ImVec4* colors = style->Colors; 267 | ImGui::StyleColorsDark(style);//Reset to base/dark theme 268 | colors[ImGuiCol_Text] = ImVec4(0.00f, 0.82f, 1.00f, 1.00f); 269 | colors[ImGuiCol_TextDisabled] = ImVec4(0.00f, 0.36f, 0.63f, 1.00f); 270 | colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.04f, 0.12f, 1.00f); 271 | colors[ImGuiCol_ChildBg] = ImVec4(0.03f, 0.04f, 0.22f, 1.00f); 272 | colors[ImGuiCol_PopupBg] = ImVec4(0.12f, 0.06f, 0.27f, 1.00f); 273 | colors[ImGuiCol_Border] = ImVec4(0.61f, 0.00f, 1.00f, 1.00f); 274 | colors[ImGuiCol_FrameBg] = ImVec4(0.00f, 0.75f, 1.00f, 0.20f); 275 | colors[ImGuiCol_FrameBgHovered] = ImVec4(0.34f, 0.00f, 1.00f, 1.00f); 276 | colors[ImGuiCol_FrameBgActive] = ImVec4(0.08f, 0.00f, 1.00f, 1.00f); 277 | colors[ImGuiCol_TitleBg] = ImVec4(0.00f, 0.81f, 0.95f, 1.00f); 278 | colors[ImGuiCol_TitleBgActive] = ImVec4(0.61f, 0.00f, 1.00f, 1.00f); 279 | colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.25f, 0.00f, 0.54f, 0.81f); 280 | colors[ImGuiCol_MenuBarBg] = ImVec4(0.61f, 0.00f, 1.00f, 1.00f); 281 | colors[ImGuiCol_ScrollbarBg] = ImVec4(0.00f, 0.88f, 1.00f, 1.00f); 282 | colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.61f, 0.00f, 1.00f, 1.00f); 283 | colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.01f, 0.00f, 1.00f, 1.00f); 284 | colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.95f, 0.19f, 0.67f, 1.00f); 285 | colors[ImGuiCol_CheckMark] = ImVec4(0.95f, 0.19f, 0.92f, 1.00f); 286 | colors[ImGuiCol_SliderGrab] = ImVec4(0.00f, 1.00f, 0.95f, 1.00f); 287 | colors[ImGuiCol_SliderGrabActive] = ImVec4(0.81f, 0.00f, 1.00f, 1.00f); 288 | colors[ImGuiCol_Button] = ImVec4(0.00f, 0.98f, 1.00f, 0.52f); 289 | colors[ImGuiCol_ButtonHovered] = ImVec4(0.94f, 0.00f, 1.00f, 0.80f); 290 | colors[ImGuiCol_ButtonActive] = ImVec4(0.01f, 0.00f, 1.00f, 1.00f); 291 | colors[ImGuiCol_Header] = ImVec4(0.00f, 0.95f, 1.00f, 0.40f); 292 | colors[ImGuiCol_HeaderHovered] = ImVec4(0.94f, 0.00f, 1.00f, 0.80f); 293 | colors[ImGuiCol_HeaderActive] = ImVec4(0.01f, 0.00f, 1.00f, 1.00f); 294 | colors[ImGuiCol_Separator] = ImVec4(0.74f, 0.00f, 1.00f, 0.50f); 295 | colors[ImGuiCol_SeparatorHovered] = ImVec4(0.34f, 0.00f, 1.00f, 0.78f); 296 | colors[ImGuiCol_SeparatorActive] = ImVec4(0.00f, 1.00f, 0.85f, 1.00f); 297 | colors[ImGuiCol_ResizeGrip] = ImVec4(0.61f, 0.00f, 1.00f, 1.00f); 298 | colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.89f, 0.26f, 0.98f, 0.67f); 299 | colors[ImGuiCol_ResizeGripActive] = ImVec4(0.00f, 0.88f, 1.00f, 0.95f); 300 | colors[ImGuiCol_Tab] = ImVec4(0.36f, 0.00f, 1.00f, 1.00f); 301 | colors[ImGuiCol_TabHovered] = ImVec4(0.00f, 0.92f, 1.00f, 0.80f); 302 | colors[ImGuiCol_TabActive] = ImVec4(0.62f, 0.00f, 0.80f, 1.00f); 303 | colors[ImGuiCol_PlotHistogram] = ImVec4(0.00f, 1.00f, 0.88f, 1.00f); 304 | style->FrameBorderSize = 0.00f; 305 | style->WindowRounding = 0.00f; 306 | style->FrameRounding = 0.00f; 307 | style->ScrollbarRounding = 0.00f; 308 | style->GrabRounding = 0.00f; 309 | } 310 | 311 | void Theme_Nord(ImGuiStyle* dst = NULL) 312 | { 313 | // Nord/Nordic GTK [Improvised] 314 | // https://github.com/EliverLara/Nordic 315 | ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); 316 | ImVec4* colors = style->Colors; 317 | ImGui::StyleColorsDark(style);//Reset to base/dark theme 318 | colors[ImGuiCol_Text] = ImVec4(0.85f, 0.87f, 0.91f, 0.88f); 319 | colors[ImGuiCol_TextDisabled] = ImVec4(0.49f, 0.50f, 0.53f, 1.00f); 320 | colors[ImGuiCol_WindowBg] = ImVec4(0.18f, 0.20f, 0.25f, 1.00f); 321 | colors[ImGuiCol_ChildBg] = ImVec4(0.16f, 0.17f, 0.20f, 1.00f); 322 | colors[ImGuiCol_PopupBg] = ImVec4(0.23f, 0.26f, 0.32f, 1.00f); 323 | colors[ImGuiCol_Border] = ImVec4(0.14f, 0.16f, 0.19f, 1.00f); 324 | colors[ImGuiCol_BorderShadow] = ImVec4(0.09f, 0.09f, 0.09f, 0.00f); 325 | colors[ImGuiCol_FrameBg] = ImVec4(0.23f, 0.26f, 0.32f, 1.00f); 326 | colors[ImGuiCol_FrameBgHovered] = ImVec4(0.56f, 0.74f, 0.73f, 1.00f); 327 | colors[ImGuiCol_FrameBgActive] = ImVec4(0.53f, 0.75f, 0.82f, 1.00f); 328 | colors[ImGuiCol_TitleBg] = ImVec4(0.16f, 0.16f, 0.20f, 1.00f); 329 | colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.16f, 0.20f, 1.00f); 330 | colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.16f, 0.16f, 0.20f, 1.00f); 331 | colors[ImGuiCol_MenuBarBg] = ImVec4(0.16f, 0.16f, 0.20f, 1.00f); 332 | colors[ImGuiCol_ScrollbarBg] = ImVec4(0.18f, 0.20f, 0.25f, 1.00f); 333 | colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.23f, 0.26f, 0.32f, 0.60f); 334 | colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.23f, 0.26f, 0.32f, 1.00f); 335 | colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.23f, 0.26f, 0.32f, 1.00f); 336 | colors[ImGuiCol_CheckMark] = ImVec4(0.37f, 0.51f, 0.67f, 1.00f); 337 | colors[ImGuiCol_SliderGrab] = ImVec4(0.51f, 0.63f, 0.76f, 1.00f); 338 | colors[ImGuiCol_SliderGrabActive] = ImVec4(0.37f, 0.51f, 0.67f, 1.00f); 339 | colors[ImGuiCol_Button] = ImVec4(0.18f, 0.20f, 0.25f, 1.00f); 340 | colors[ImGuiCol_ButtonHovered] = ImVec4(0.51f, 0.63f, 0.76f, 1.00f); 341 | colors[ImGuiCol_ButtonActive] = ImVec4(0.37f, 0.51f, 0.67f, 1.00f); 342 | colors[ImGuiCol_Header] = ImVec4(0.51f, 0.63f, 0.76f, 1.00f); 343 | colors[ImGuiCol_HeaderHovered] = ImVec4(0.53f, 0.75f, 0.82f, 1.00f); 344 | colors[ImGuiCol_HeaderActive] = ImVec4(0.37f, 0.51f, 0.67f, 1.00f); 345 | colors[ImGuiCol_SeparatorHovered] = ImVec4(0.56f, 0.74f, 0.73f, 1.00f); 346 | colors[ImGuiCol_SeparatorActive] = ImVec4(0.53f, 0.75f, 0.82f, 1.00f); 347 | colors[ImGuiCol_ResizeGrip] = ImVec4(0.53f, 0.75f, 0.82f, 0.86f); 348 | colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.61f, 0.74f, 0.87f, 1.00f); 349 | colors[ImGuiCol_ResizeGripActive] = ImVec4(0.37f, 0.51f, 0.67f, 1.00f); 350 | colors[ImGuiCol_Tab] = ImVec4(0.18f, 0.20f, 0.25f, 1.00f); 351 | colors[ImGuiCol_TabHovered] = ImVec4(0.22f, 0.24f, 0.31f, 1.00f); 352 | colors[ImGuiCol_TabActive] = ImVec4(0.23f, 0.26f, 0.32f, 1.00f); 353 | colors[ImGuiCol_TabUnfocused] = ImVec4(0.13f, 0.15f, 0.18f, 1.00f); 354 | colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.17f, 0.19f, 0.23f, 1.00f); 355 | colors[ImGuiCol_PlotHistogram] = ImVec4(0.56f, 0.74f, 0.73f, 1.00f); 356 | colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.53f, 0.75f, 0.82f, 1.00f); 357 | colors[ImGuiCol_TextSelectedBg] = ImVec4(0.37f, 0.51f, 0.67f, 1.00f); 358 | colors[ImGuiCol_NavHighlight] = ImVec4(0.53f, 0.75f, 0.82f, 0.86f); 359 | style->WindowBorderSize = 1.00f; 360 | style->ChildBorderSize = 1.00f; 361 | style->PopupBorderSize = 1.00f; 362 | style->FrameBorderSize = 1.00f; 363 | } 364 | 365 | }; 366 | -------------------------------------------------------------------------------- /ImCandy/gradient.h: -------------------------------------------------------------------------------- 1 | /* 2 | https://github.com/Eren121/CppColorGradient 3 | 4 | MIT License 5 | 6 | Copyright (c) 2021 Eren121 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | #ifndef Gradient_H 28 | #define Gradient_H 29 | 30 | #define _USE_MATH_DEFINES 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #define GRADIENT_KEY_DEFAULT_PRECISION double 42 | #define GRADIENT_COLOR_PRECISION_TYPE double 43 | #define GRADIENT_VALARRAY_FORMAT_OPEN "(" 44 | #define GRADIENT_VALARRAY_FORMAT_CLOSE ")" 45 | #define GRADIENT_VALARRAY_FORMAT_SEPARATOR ", " 46 | 47 | ///////////////////////////////////////////////////////////////////////////// 48 | // Interpolation method //////////////////////////////////////////////////// 49 | ///////////////////////////////////////////////////////////////////////////// 50 | 51 | namespace gradient { 52 | 53 | template 54 | T linear_interpolation(T x) { 55 | return x; 56 | } 57 | 58 | template 59 | T cosine_interpolation(T x) { 60 | return T(1) - (cos(x * T(M_PI)) + T(1)) / T(2); 61 | } 62 | } 63 | 64 | ///////////////////////////////////////////////////////////////////////////// 65 | // Gradient //////////////////////////////////////////////////////////////// 66 | ///////////////////////////////////////////////////////////////////////////// 67 | 68 | namespace gradient { 69 | using default_precision = GRADIENT_KEY_DEFAULT_PRECISION; 70 | template using Interpolation = std::function; 71 | 72 | template 73 | class GradientBase { 74 | public: 75 | explicit GradientBase(const Interpolation& interpolation) 76 | : interpolationMethod(interpolation) {} 77 | GradientBase() 78 | : interpolationMethod(linear_interpolation) {} 79 | virtual ~GradientBase() = default; 80 | 81 | Interpolation& interpolation() { return this->interpolationMethod; } 82 | const Interpolation& interpolation() const { return this->interpolationMethod; } 83 | void setInterpolation(const Interpolation& interp) { this->interpolationMethod = interp;} 84 | 85 | T interpolate(const T& lowerBound, const T& upperBound, precision r) const { 86 | assert(interpolationMethod); 87 | r = interpolationMethod(r); 88 | return upperBound * r + lowerBound * (precision(1) - r); 89 | } 90 | 91 | private: 92 | Interpolation interpolationMethod; 93 | }; 94 | 95 | template 96 | class LinearGradient : public GradientBase { 97 | public: 98 | using GradientBase::GradientBase; 99 | ~LinearGradient() override = default; 100 | T& operator[](precision keyPoint); 101 | const T& operator[](precision keyPoint) const; 102 | T operator()(precision point) const; 103 | 104 | private: 105 | std::map keyPoints; 106 | }; 107 | } 108 | 109 | ///////////////////////////////////////////////////////////////////////////// 110 | // Convenience operators /////////////////////////////////////////////////// 111 | ///////////////////////////////////////////////////////////////////////////// 112 | 113 | namespace gradient { 114 | 115 | namespace operators { 116 | 117 | template 118 | std::ostream &operator<<(std::ostream &ostream, const T &valarray) { 119 | ostream << GRADIENT_VALARRAY_FORMAT_OPEN; 120 | bool firstValue = true; 121 | std::for_each(begin(valarray), end(valarray), [&firstValue, &ostream](const value_type &element) { 122 | if (!firstValue) { 123 | ostream << GRADIENT_VALARRAY_FORMAT_SEPARATOR; 124 | } else { 125 | firstValue = false; 126 | } 127 | ostream << element; 128 | }); 129 | ostream << GRADIENT_VALARRAY_FORMAT_CLOSE; 130 | return ostream; 131 | } 132 | } 133 | } 134 | 135 | ///////////////////////////////////////////////////////////////////////////// 136 | // LinearGradient implementation /////////////////////////////////////////// 137 | ///////////////////////////////////////////////////////////////////////////// 138 | 139 | namespace gradient { 140 | 141 | template 142 | T &LinearGradient::operator[](precision keyPoint) { 143 | return this->keyPoints[keyPoint]; 144 | } 145 | 146 | template 147 | const T& LinearGradient::operator[](precision keyPoint) const { 148 | return this->keyPoints.at(keyPoint); 149 | } 150 | 151 | template 152 | T LinearGradient::operator()(precision point) const { 153 | 154 | assert(!this->keyPoints.empty()); 155 | T returnValue; 156 | 157 | const auto upper_bound_it = this->keyPoints.upper_bound(point); 158 | 159 | 160 | if(upper_bound_it == this->keyPoints.end()) { 161 | returnValue = this->keyPoints.rbegin()->second; 162 | } 163 | else { 164 | if (upper_bound_it == this->keyPoints.begin()) { 165 | returnValue = this->keyPoints.begin()->second; 166 | } else { 167 | const auto lower_bound_it = prev(upper_bound_it); 168 | 169 | const T &min = lower_bound_it->second; 170 | const T &max = upper_bound_it->second; 171 | const precision min_point = lower_bound_it->first; 172 | const precision max_point = upper_bound_it->first; 173 | const precision ratio = (point - min_point) / (max_point - min_point); 174 | returnValue = this->interpolate(min, max, ratio); 175 | } 176 | } 177 | 178 | return returnValue; 179 | } 180 | } 181 | 182 | ///////////////////////////////////////////////////////////////////////////// 183 | // User-Defined Types ////////////////////////////////////////////////////// 184 | ///////////////////////////////////////////////////////////////////////////// 185 | 186 | namespace gradient { 187 | 188 | using Color = std::valarray; 189 | using LinearColorGradient = LinearGradient; 190 | 191 | template class LinearGradient; 192 | template void GradientBase::setInterpolation(const Interpolation &interpolation); 193 | } 194 | 195 | #endif 196 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Raais N. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImguiCandy 2 | Color utils, Themes and other cool stuff for [Dear ImGui](https://github.com/ocornut/imgui) 3 | ## Usage 4 | ```cpp 5 | #include "candy.h" 6 | ``` 7 | ## Utils 8 | These functions are to be used inside a loop, hence the use of static/global variables. 9 | ```cpp 10 | ImVec4 Rainbow(double &static_ratio, double step = 0.01); 11 | 12 | ImVec4 Gradient2(ImVec4 col1, ImVec4 col2, double &static_ratio, double step = 0.01); 13 | 14 | ImVec4 Gradient3(ImVec4 col1, ImVec4 col2, ImVec4 col3, double &static_ratio, double step = 0.01); 15 | ``` 16 | #### Example 17 | ```cpp 18 | //Rainbow 19 | static double s0 = 0.0; 20 | ImGui::PushStyleColor(ImGuiCol_Button, ImCandy::Rainbow(s0)); 21 | ``` 22 | ![rainbow](https://user-images.githubusercontent.com/64605172/145681647-b9445ec7-5f4d-4c5f-98b8-eea840503392.gif) 23 | ```cpp 24 | //Gradient2 25 | static double s1 = 0.0; 26 | ImGui::PushStyleColor(ImGuiCol_WindowBg, ImCandy::Gradient2(IV4_VIOLET, IV4_BUBBLEGUM, s1)); 27 | ``` 28 | ![gradient](https://user-images.githubusercontent.com/64605172/145683127-8439a3fb-8a44-4642-94a4-97dd46c5349b.gif) 29 | ## Themes 30 | - Blender Dark [Improvised] 31 | ```cpp 32 | ImCandy::Theme_Blender(); 33 | ``` 34 | ![blender](https://user-images.githubusercontent.com/64605172/145681657-dc9786ae-5f79-4eca-90a6-197579b94fa5.png) 35 | - Cyberpunk Neon [Improvised] 36 | ```cpp 37 | ImCandy::Theme_Cyberpunk(); 38 | ``` 39 | ![cyberpunk](https://user-images.githubusercontent.com/64605172/145681654-2ebea5fc-ec99-44ba-a808-d20721415f6c.png) 40 | - Nord/Nordic GTK [Improvised] 41 | ```cpp 42 | ImCandy::Theme_Nord(); 43 | ``` 44 | ![nord](https://user-images.githubusercontent.com/64605172/145686658-b93073ab-1161-4898-bccf-b6f2a757d13a.png) 45 | ## Contribute 46 | Submit your own themes by opening an [issue](https://github.com/Raais/ImguiCandy/issues) or [pull request](https://github.com/Raais/ImguiCandy/pulls). 47 | --------------------------------------------------------------------------------