mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
fixed bug
This commit is contained in:
@@ -17,9 +17,13 @@ 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(float r, float g, float b, float a);
|
||||||
Color(const Vector4& vec);
|
static Color FromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||||
|
explicit 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};}
|
|
||||||
|
[[nodiscard]] static Color Red() {return {1.f, 0.f, 0.f, 1.f};}
|
||||||
|
[[nodiscard]] static Color Green() {return {0.f, 1.f, 0.f, 1.f};}
|
||||||
|
[[nodiscard]] static Color Blue() {return {0.f, 0.f, 1.f, 1.f};}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -14,16 +14,23 @@ 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;
|
return Color( (*this * (1.f - ratio)) + (other * ratio) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Color::Color(float r, float g, float, float b, float a) : Vector4(r,g,b,a)
|
Color::Color(float r, float g, float b, float a) : Vector4(r,g,b,a)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Color::Color(const Vector4 &vec) : Vector4(vec.x, vec.y, vec.z, vec.w)
|
Color::Color(const Vector4 &vec) : Vector4(vec)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color Color::FromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
|
||||||
|
{
|
||||||
|
|
||||||
|
return Color{Vector4(r, g, b, a) / 255.f};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user