PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
PixelBullet::Color Class Reference

A polished Color class storing RGBA values in a glm::vec4. More...

#include <Color.hpp>

Public Types

enum class  Type { RGBA , ARGB , RGB }
 

Public Member Functions

constexpr Color (float r, float g, float b, float a=1.0f) noexcept
 Constructs a Color from individual float components (0.0f to 1.0f).
 
constexpr Color (uint32_t i, Type type=Type::RGB) noexcept
 Constructs a Color from a packed 32-bit integer. The 'type' parameter defines the component order.
 
 Color (std::string hex, float a=1.0f)
 Constructs a Color from a hexadecimal string (e.g. "#FF00FF").
 
constexpr Color Lerp (const Color &other, float t) const noexcept
 Returns a color that is the linear interpolation between this and another color.
 
Color Normalize () const
 Normalizes this color (treating it as a 4D vector).
 
constexpr float Length2 () const noexcept
 Returns the squared length of the color vector.
 
float Length () const noexcept
 Returns the length of the color vector.
 
constexpr uint32_t GetInt (Type type=Type::RGBA) const noexcept
 Returns the packed 32-bit integer representation.
 
std::string GetHex () const
 Returns the hexadecimal string representation (e.g. "#FF00FF").
 
constexpr float operator[] (uint32_t i) const noexcept
 Component access (0: red, 1: green, 2: blue, 3: alpha)
 
constexpr float & operator[] (uint32_t i)
 
constexpr bool operator== (const Color &rhs) const noexcept
 
constexpr bool operator!= (const Color &rhs) const noexcept
 
constexpr Coloroperator+= (const Color &rhs) noexcept
 
constexpr Coloroperator-= (const Color &rhs) noexcept
 
constexpr Coloroperator*= (const Color &rhs) noexcept
 
constexpr Coloroperator/= (const Color &rhs) noexcept
 
constexpr Coloroperator+= (float rhs) noexcept
 
constexpr Coloroperator-= (float rhs) noexcept
 
constexpr Coloroperator*= (float rhs) noexcept
 
constexpr Coloroperator/= (float rhs) noexcept
 

Static Public Attributes

static const Color Clear = Color(0x00000000, Color::Type::RGBA)
 
static const Color Black = Color(0x000000FF, Color::Type::RGBA)
 
static const Color Grey = Color(0x808080, Color::Type::RGB)
 
static const Color Silver = Color(0xC0C0C0, Color::Type::RGB)
 
static const Color White = Color(0xFFFFFF, Color::Type::RGB)
 
static const Color Maroon = Color(0x800000, Color::Type::RGB)
 
static const Color Red = Color(0xFF0000, Color::Type::RGB)
 
static const Color Olive = Color(0x808000, Color::Type::RGB)
 
static const Color Yellow = Color(0xFFFF00, Color::Type::RGB)
 
static const Color Green = Color(0x00FF00, Color::Type::RGB)
 
static const Color Lime = Color(0x008000, Color::Type::RGB)
 
static const Color Teal = Color(0x008080, Color::Type::RGB)
 
static const Color Aqua = Color(0x00FFFF, Color::Type::RGB)
 
static const Color Navy = Color(0x000080, Color::Type::RGB)
 
static const Color Blue = Color(0x0000FF, Color::Type::RGB)
 
static const Color Purple = Color(0x800080, Color::Type::RGB)
 
static const Color Fuchsia = Color(0xFF00FF, Color::Type::RGB)
 

Friends

constexpr Color operator+ (const Color &lhs, const Color &rhs) noexcept
 
constexpr Color operator- (const Color &lhs, const Color &rhs) noexcept
 
constexpr Color operator* (const Color &lhs, const Color &rhs) noexcept
 
constexpr Color operator/ (const Color &lhs, const Color &rhs) noexcept
 
constexpr Color operator* (float lhs, const Color &rhs) noexcept
 
constexpr Color operator* (const Color &lhs, float rhs) noexcept
 
constexpr Color operator/ (const Color &lhs, float rhs) noexcept
 
constexpr Color operator+ (const Color &lhs, float rhs) noexcept
 
constexpr Color operator- (const Color &lhs, float rhs) noexcept
 
const Nodeoperator>> (const Node &node, Color &color)
 
Nodeoperator<< (Node &node, const Color &color)
 

Detailed Description

A polished Color class storing RGBA values in a glm::vec4.

Constructor & Destructor Documentation

◆ Color() [1/3]

PixelBullet::Color::Color ( float r,
float g,
float b,
float a = 1.0f )
inlineconstexprnoexcept

Constructs a Color from individual float components (0.0f to 1.0f).

◆ Color() [2/3]

PixelBullet::Color::Color ( uint32_t i,
Type type = Type::RGB )
inlineconstexprnoexcept

Constructs a Color from a packed 32-bit integer. The 'type' parameter defines the component order.

◆ Color() [3/3]

PixelBullet::Color::Color ( std::string hex,
float a = 1.0f )
inlineexplicit

Constructs a Color from a hexadecimal string (e.g. "#FF00FF").

Member Function Documentation

◆ GetHex()

std::string PixelBullet::Color::GetHex ( ) const
inline

Returns the hexadecimal string representation (e.g. "#FF00FF").

◆ GetInt()

uint32_t PixelBullet::Color::GetInt ( Type type = Type::RGBA) const
inlineconstexprnoexcept

Returns the packed 32-bit integer representation.

◆ Length()

float PixelBullet::Color::Length ( ) const
inlinenoexcept

Returns the length of the color vector.

◆ Length2()

float PixelBullet::Color::Length2 ( ) const
inlineconstexprnoexcept

Returns the squared length of the color vector.

◆ Lerp()

Color PixelBullet::Color::Lerp ( const Color & other,
float t ) const
inlineconstexprnoexcept

Returns a color that is the linear interpolation between this and another color.

◆ Normalize()

Color PixelBullet::Color::Normalize ( ) const
inline

Normalizes this color (treating it as a 4D vector).

◆ operator[]()

float PixelBullet::Color::operator[] ( uint32_t i) const
inlineconstexprnoexcept

Component access (0: red, 1: green, 2: blue, 3: alpha)


The documentation for this class was generated from the following files: