1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-15 21:16:33 +00:00
openmw/components/misc/color.hpp
2025-08-28 03:22:33 +03:00

43 lines
1,000 B
C++

#ifndef COMPONENTS_MISC_COLOR
#define COMPONENTS_MISC_COLOR
#include <string>
#include <osg/Vec4>
namespace Misc
{
class Color
{
explicit Color(osg::Vec4&& value)
: mValue(value)
{
}
public:
Color() = default;
Color(float r, float g, float b, float a);
float r() const { return mValue.r(); }
float g() const { return mValue.g(); }
float b() const { return mValue.b(); }
float a() const { return mValue.a(); }
std::string toString() const;
static Color fromHex(std::string_view hex);
static Color fromRGB(unsigned int value);
static Color fromVec(osg::Vec4f value);
std::string toHex() const;
unsigned int toRGBA() const { return mValue.asRGBA(); }
osg::Vec4f toVec() const { return mValue; }
friend bool operator==(const Color& l, const Color& r);
private:
osg::Vec4 mValue;
};
}
#endif // !COMPONENTS_MISC_COLOR