cleaning up Color struct a little

This commit is contained in:
Noel Berry
2021-01-30 19:48:14 -08:00
parent add76cd968
commit 1e1e150411
2 changed files with 36 additions and 2 deletions

View File

@ -17,6 +17,7 @@ namespace Blah
Color(int rgb, float alpha);
Color(uint8_t r, uint8_t g, uint8_t b);
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
Color(const Vec4& vec4);
// Parses a Hex string in the format of "#00000000" or "0x00000000" or "00000000"
Color(const char* hexCstr);
@ -28,12 +29,20 @@ namespace Blah
// The buffer must be at least 8 bytes long
void to_hex_rgba(char* buffer) const;
// Returns an RGBA hex string of the color
String to_hex_rgba() const;
// Sets a Hex string to the given buffer, in the format of RRGGBB
// The buffer must be at least 6 bytes long
void to_hex_rgb(char* buffer) const;
// Returns an RGB hex string of the color
String to_hex_rgb() const;
// Convers the Color to a uint32_t
uint32_t to_rgba() const;
// Converts the Color to a Vec4
Vec4 to_vec4() const;
// Returns a RGBA Color representation of the integer value
@ -42,6 +51,7 @@ namespace Blah
// Returns a RGB Color representation of the integer value, with Alpha = 255
static Color from_rgb(uint32_t value);
// Lerps between two colors
static Color lerp(Color a, Color b, float amount);
// Mutliplties the Color
@ -49,7 +59,11 @@ namespace Blah
// assignment from int
Color& operator= (const int rgb);
// comparisons
bool operator ==(const Color& rhs) const;
bool operator !=(const Color& rhs) const;
static const Color transparent;
static const Color white;
static const Color black;