added constructors

This commit is contained in:
2024-05-07 02:12:16 +03:00
parent f996f10b4c
commit 768c8b133a
2 changed files with 13 additions and 0 deletions

View File

@@ -17,6 +17,9 @@ namespace uml::color
class Color : public Vector4 class Color : public Vector4
{ {
public: public:
Color(float r, float g, float, float b, float a = 1.f);
Color(const Vector4& vec);
[[nodiscard]] Color Blend(const Color& other, float ratio) const; [[nodiscard]] Color Blend(const Color& other, float ratio) const;
explicit operator Vector4() {return {x,y,z,w};}
}; };
} }

View File

@@ -13,6 +13,16 @@ namespace uml::color
} }
Color Color::Blend(const Color &other, float ratio) const Color Color::Blend(const Color &other, float ratio) const
{
return *this * (1.f - std::clamp(ratio, 0.f, 1.f)) + other * ratio;
}
Color::Color(float r, float g, float, float b, float a) : Vector4(r,g,b,a)
{
}
Color::Color(const Vector4 &vec) : Vector4(vec.x, vec.y, vec.z, vec.w)
{ {
} }