mirror of
https://github.com/NoelFB/blah.git
synced 2025-09-13 13:24:26 +08:00
cleaning up color struct
This commit is contained in:
@ -1,23 +1,11 @@
|
||||
#include <blah/numerics/color.h>
|
||||
#include <blah/numerics/vec3.h>
|
||||
#include <blah/numerics/vec4.h>
|
||||
|
||||
using namespace Blah;
|
||||
|
||||
char const hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
|
||||
Vec3 Color::to_vec3() const
|
||||
{
|
||||
return Vec3(r / 255.0f, g / 255.0f, b / 255.0f);
|
||||
}
|
||||
|
||||
Vec4 Color::to_vec4() const
|
||||
{
|
||||
return Vec4(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
}
|
||||
|
||||
String Color::to_hex_rgba() const
|
||||
{
|
||||
static const char* hex = "0123456789ABCDEF";
|
||||
|
||||
String str = "00000000";
|
||||
str[0] = hex[(r & 0xF0) >> 4];
|
||||
str[1] = hex[(r & 0x0F) >> 0];
|
||||
@ -32,6 +20,8 @@ String Color::to_hex_rgba() const
|
||||
|
||||
String Color::to_hex_rgb() const
|
||||
{
|
||||
static const char* hex = "0123456789ABCDEF";
|
||||
|
||||
String str = "000000";
|
||||
str[0] = hex[(r & 0xF0) >> 4];
|
||||
str[1] = hex[(r & 0x0F) >> 0];
|
||||
|
Reference in New Issue
Block a user