cleaning up color struct

This commit is contained in:
Noel Berry
2021-05-25 21:31:18 -07:00
parent 6f0ac3e8c2
commit 5ba620c066
3 changed files with 17 additions and 21 deletions

View File

@ -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];