#include "Math/Color.h" namespace XCEngine { namespace Math { Color Color::Lerp(const Color& a, const Color& b, float t) { t = std::clamp(t, 0.0f, 1.0f); return Color( a.r + (b.r - a.r) * t, a.g + (b.g - a.g) * t, a.b + (b.b - a.b) * t, a.a + (b.a - a.a) * t ); } uint32_t Color::ToRGBA() const { uint32_t r = static_cast(std::clamp(r * 255.0f, 0.0f, 255.0f)); uint32_t g = static_cast(std::clamp(g * 255.0f, 0.0f, 255.0f)); uint32_t b = static_cast(std::clamp(b * 255.0f, 0.0f, 255.0f)); uint32_t a = static_cast(std::clamp(a * 255.0f, 0.0f, 255.0f)); return (r << 24) | (g << 16) | (b << 8) | a; } Vector3 Color::ToVector3() const { return Vector3(r, g, b); } Vector4 Color::ToVector4() const { return Vector4(r, g, b, a); } Color Color::operator+(const Color& other) const { return Color(r + other.r, g + other.g, b + other.b, a + other.a); } Color Color::operator-(const Color& other) const { return Color(r - other.r, g - other.g, b - other.b, a - other.a); } Color Color::operator*(float scalar) const { return Color(r * scalar, g * scalar, b * scalar, a * scalar); } Color Color::operator/(float scalar) const { return Color(r / scalar, g / scalar, b / scalar, a / scalar); } } // namespace Math } // namespace XCEngine