Elaztek Developer Hub
Blamite Game Engine - Strings  00402.09.29.23.0627.blamite
A library containing general purpose utilities and classes for use in multiple projects.
BlamColor.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
5 
6 #ifdef STRINGS_EXPORTS
7 #define STRINGS_API __declspec(dllexport)
8 #else
9 #define STRINGS_API __declspec(dllimport)
10 #endif
11 
12 typedef unsigned char byte;
13 
20 {
21 private:
22  byte convert_float_clamped(float f);
23 
24 public:
25  byte r = 255;
26  byte g = 255;
27  byte b = 255;
28  byte a = 255;
29 
30  BlamColor();
31 
39  BlamColor(byte _r, byte _g, byte _b);
40 
49  BlamColor(byte _r, byte _g, byte _b, byte _a);
50 
51  bool operator==(const BlamColor& other);
52 
58  std::string ToString();
59 
65  float GetRedAsFloat();
66 
72  float GetGreenAsFloat();
73 
79  float GetBlueAsFloat();
80 
86  float GetAlphaAsFloat();
87 
96  int GetColorAsInt();
97 
114  std::string ToString(std::string format);
115 
121  std::string ToStringForCSS();
122 
132  bool FromString(std::string string);
133 
143  BlamVector4 ToVector4();
144 
153  void FromVector4(BlamVector4 vector);
154 
165  bool Equals(BlamColor other_color);
166 
176  BlamVector3 ToVector3();
177 
186  void FromVector3(BlamVector3 vector);
187 };
BlamStrings::Utils::String::Split
STRINGS_API std::vector< std::string > Split(std::string string, std::string splitter)
Splits a string around any instance of a substring.
Definition: string.cpp:136
BlamColor::BlamColor
BlamColor()
Definition: BlamColor.cpp:25
BlamColor::b
byte b
The Blue value of the color.
Definition: BlamColor.h:27
BlamVector4::w
float w
The W-coordinate of the 4D vector.
Definition: vector.h:167
string.h
BlamColor::GetColorAsInt
int GetColorAsInt()
Gets the color's value as an integer.
Definition: BlamColor.cpp:74
BlamVector3::y
float y
The Y-coordinate of the 3D vector, representing horizontal Y (depth) position.
Definition: vector.h:83
BlamVector3::x
float x
The X-coordinate of the 3D vector, representing horizontal X (width) position.
Definition: vector.h:82
BlamVector3
Structure representing a 3D vector.
Definition: vector.h:80
BlamColor.h
BlamVector4::y
float y
The Y-coordinate of the 4D vector.
Definition: vector.h:165
BlamColor::ToVector4
BlamVector4 ToVector4()
Converts the color into a BlamVector4.
Definition: BlamColor.cpp:143
BlamVector3::z
float z
The Z-coordinate of the 3D vector, representing vertical position.
Definition: vector.h:84
BlamColor::FromVector3
void FromVector3(BlamVector3 vector)
Parses color information from a BlamVector3.
Definition: BlamColor.cpp:201
byte
unsigned char byte
Definition: BlamColor.h:12
BlamVector4
Structure representing a 4D vector.
Definition: vector.h:162
BlamStrings::Utils::String::Replace
STRINGS_API std::string Replace(std::string orig, std::string to_replace, std::string replace_with)
Replaces part of a string with another string.
Definition: string.cpp:94
BlamColor::a
byte a
The Alpha value of the color.
Definition: BlamColor.h:28
STRINGS_API
#define STRINGS_API
Definition: BlamColor.h:9
BlamColor::GetBlueAsFloat
float GetBlueAsFloat()
Gets the color's red value as a float, between 0 and 1.
Definition: BlamColor.cpp:64
BlamColor::operator==
bool operator==(const BlamColor &other)
Definition: BlamColor.cpp:208
BlamColor::GetRedAsFloat
float GetRedAsFloat()
Gets the color's red value as a float, between 0 and 1.
Definition: BlamColor.cpp:54
vector.h
uuids::to_string
std::basic_string< CharT, Traits, Allocator > to_string(uuid const &id)
Definition: uuid.h:581
BlamColor::FromVector4
void FromVector4(BlamVector4 vector)
Parses color information from a BlamVector4.
Definition: BlamColor.cpp:156
BlamColor::GetGreenAsFloat
float GetGreenAsFloat()
Gets the color's red value as a float, between 0 and 1.
Definition: BlamColor.cpp:59
uuids::operator==
bool operator==(uuid const &lhs, uuid const &rhs) noexcept
Definition: uuid.h:563
BlamColor::ToString
std::string ToString()
Converts the color value to a string.
Definition: BlamColor.cpp:49
BlamColor::ToStringForCSS
std::string ToStringForCSS()
Converts the color to a string that can be used with CSS.
Definition: BlamColor.cpp:105
BlamColor::g
byte g
The Green value of the color.
Definition: BlamColor.h:26
BlamColor::FromString
bool FromString(std::string string)
Attempts to set color information from a string.
Definition: BlamColor.cpp:110
BlamColor::GetAlphaAsFloat
float GetAlphaAsFloat()
Gets the color's red value as a float, between 0 and 1.
Definition: BlamColor.cpp:69
BlamVector4::x
float x
The X-coordinate of the 4D vector.
Definition: vector.h:164
BlamColor
Class representing a color.
Definition: BlamColor.h:19
BlamColor::r
byte r
The Red value of the color.
Definition: BlamColor.h:25
BlamVector4::z
float z
The Z-coordinate of the 4D vector.
Definition: vector.h:166
BlamColor::ToVector3
BlamVector3 ToVector3()
Converts the color into a BlamVector3.
Definition: BlamColor.cpp:189
BlamColor::Equals
bool Equals(BlamColor other_color)
Checks if this color is equal to another color.
Definition: BlamColor.cpp:164