pound-emu_pound/gui/color.cpp
Ronald Caesar ba45834583
feat!: rewrote program in a data oriented style.
This is because the source code is objected oriented which is not cpu cache
friendly, making the program slower than it has to be. Yuzu's entire
codebase is written in a objected oriented way and I wonder how much faster
it could if they had use DoD principles from the very beginning.

That's why I want to instill DoD fundamentals early on so this won't be a
problem going forward.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-08-02 04:05:05 -04:00

34 lines
997 B
C++
Executable file

#include "color.h"
ImVec4 gui::color::with_alpha(const ImVec4& color, float alpha)
{
auto vec = ImVec4(color.x, color.y, color.z, alpha);
return vec;
}
ImVec4 gui::color::lighten(const ImVec4& color, float amount)
{
float x = std::min(1.0F, color.x + amount);
float y = std::min(1.0F, color.y + amount);
float z = std::min(1.0F, color.z + amount);
auto vec = ImVec4(x, y, z, color.w);
return vec;
}
ImVec4 gui::color::darken(const ImVec4& color, float amount)
{
float x = std::max(0.0F, color.x - amount);
float y = std::max(0.0F, color.y - amount);
float z = std::max(0.0F, color.z - amount);
auto vec = ImVec4(x, y, z, color.w);
return vec;
}
ImVec4 gui::color::from_hex(uint32_t hex, float alpha)
{
float r = static_cast<float>(((hex >> 16) & 0xFF)) / 255.0f;
float g = static_cast<float>(((hex >> 8) & 0xFF)) / 255.0f;
float b = static_cast<float>((hex & 0xFF)) / 255.0f;
auto vec = ImVec4(r, g, b, alpha);
return vec;
}