Nebula
Loading...
Searching...
No Matches
Util::Color Class Reference

#include <color.h>

Detailed Description

Represents colors by four single point (32-bit) floating point numbers.

Inherits Math::vec4.

Public Member Functions

 Color ()=default
 
 Color (const Color &c)=default
 
 Color (float r, float g, float b, float a)
 Construct from individual single precision floats.
 
 Color (const Math::vec4 &v)
 Copy constructor from vec4.
 
 Color (const Math::vec3 &v)
 Copy constructor from vec3, alpha is set to 1.
 
 Color (uint32_t argb)
 converts byte order A|R|G|B to 0..1 floats
 
 Color (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 Construct from individual 8 bit channels.
 
- Public Member Functions inherited from Math::vec4
 vec4 ()=default
 default constructor, NOTE: does NOT setup components!
 
 vec4 (scalar x, scalar y, scalar z, scalar w)
 construct from values
 
 vec4 (scalar v)
 construct from single value
 
 vec4 (const vec4 &rhs)=default
 copy constructor
 
 vec4 (const vec3 &rhs, float w)
 copy constructor from vec3
 
 vec4 (const __m128 &rhs)
 construct from SSE 128 byte float array
 
void operator= (const __m128 &rhs)
 assign an vmVector4
 
void operator+= (const vec4 &rhs)
 inplace add
 
void operator-= (const vec4 &rhs)
 inplace sub
 
void operator*= (scalar s)
 inplace scalar multiply
 
void operator*= (const vec4 &rhs)
 muliply by a vector component-wise
 
void operator/= (const vec4 &rhs)
 divide by a vector component-wise
 
bool operator== (const vec4 &rhs) const
 equality operator
 
bool operator!= (const vec4 &rhs) const
 inequality operator
 
void load (const scalar *ptr)
 load content from 16-byte-aligned memory
 
void loadu (const scalar *ptr)
 load content from unaligned memory
 
void store (scalar *ptr) const
 write content to 16-byte-aligned memory through the write cache
 
void storeu (scalar *ptr) const
 write content to unaligned memory through the write cache
 
void store3 (scalar *ptr) const
 write content to 16-byte-aligned memory through the write cache
 
void storeu3 (scalar *ptr) const
 write content to unaligned memory through the write cache
 
void stream (scalar *ptr) const
 stream content to 16-byte-aligned memory circumventing the write-cache
 
void load_float3 (const void *ptr, float w)
 load 3 floats into x,y,z from unaligned memory
 
void load_ubyte4n (const void *ptr)
 load from UByte4N packed vector
 
void load_byte4n (const void *ptr)
 load from Byte4N packed vector
 
void set (scalar x, scalar y, scalar z, scalar w)
 set content
 
template<int X, int Y, int Z, int W>
vec4 swizzle (const vec4 &v)
 swizzle vector
 
scalaroperator[] (const int index)
 read-only access to indexed component
 
scalar operator[] (const int index) const
 read-only access to indexed component
 
 operator vec3 () const
 implicit vec3 conversion operator
 

Static Public Member Functions

static Color RGBA (uint32_t rgba)
 Create color from unsigned int (A|R|G|B) -> 0..1 floats.
 
static Color ARGB (uint32_t argb)
 Create color from unsigned int (R|G|B|A) -> 0..1 floats.
 

Static Public Attributes

static const Color red = Color(0xFFFF0000)
 Predefined color. (0xFF0000)
 
static const Color green = Color(0xFF00FF00)
 Predefined color. (0x00FF00)
 
static const Color blue = Color(0xFF0000FF)
 Predefined color. (0x0000FF)
 
static const Color yellow = Color(0xFFFFFF00)
 Predefined color. (0xFFFF00)
 
static const Color purple = Color(0xFFA020F0)
 Predefined color. (0xA020F0)
 
static const Color orange = Color(0xFFFFA500)
 Predefined color. (0xFFA500)
 
static const Color black = Color(0xFF000000)
 Predefined color. (0x000000)
 
static const Color white = Color(0xFFFFFFFF)
 Predefined color. (0xFFFFFF)
 
static const Color gray = Color(0xFFBEBEBE)
 Predefined color. (0xBEBEBE)
 

Additional Inherited Members

- Public Attributes inherited from Math::vec4
union { 
 
   struct { 
 
      float   x 
 
      float   y 
 
      float   z 
 
      float   w 
 
   }  
 
   __m128   vec 
 
   float   v [4] 
 
};  
 

Constructor & Destructor Documentation

◆ Color() [1/7]

Util::Color::Color ( )
default

◆ Color() [2/7]

Util::Color::Color ( const Color & c)
default

◆ Color() [3/7]

__forceinline Util::Color::Color ( float r,
float g,
float b,
float a )

Construct from individual single precision floats.

◆ Color() [4/7]

__forceinline Util::Color::Color ( const Math::vec4 & v)

Copy constructor from vec4.

◆ Color() [5/7]

__forceinline Util::Color::Color ( const Math::vec3 & v)

Copy constructor from vec3, alpha is set to 1.

◆ Color() [6/7]

__forceinline Util::Color::Color ( uint32_t argb)

converts byte order A|R|G|B to 0..1 floats

◆ Color() [7/7]

__forceinline Util::Color::Color ( uint8_t r,
uint8_t g,
uint8_t b,
uint8_t a )
explicit

Construct from individual 8 bit channels.

Member Function Documentation

◆ ARGB()

__forceinline Color Util::Color::ARGB ( uint32_t argb)
static

Create color from unsigned int (R|G|B|A) -> 0..1 floats.

◆ RGBA()

__forceinline Color Util::Color::RGBA ( uint32_t rgba)
static

Create color from unsigned int (A|R|G|B) -> 0..1 floats.

Member Data Documentation

◆ black

const Color Util::Color::black = Color(0xFF000000)
static

Predefined color. (0x000000)

◆ blue

const Color Util::Color::blue = Color(0xFF0000FF)
static

Predefined color. (0x0000FF)

◆ gray

const Color Util::Color::gray = Color(0xFFBEBEBE)
static

Predefined color. (0xBEBEBE)

◆ green

const Color Util::Color::green = Color(0xFF00FF00)
static

Predefined color. (0x00FF00)

◆ orange

const Color Util::Color::orange = Color(0xFFFFA500)
static

Predefined color. (0xFFA500)

◆ purple

const Color Util::Color::purple = Color(0xFFA020F0)
static

Predefined color. (0xA020F0)

◆ red

const Color Util::Color::red = Color(0xFFFF0000)
static

Predefined color. (0xFF0000)

◆ white

const Color Util::Color::white = Color(0xFFFFFFFF)
static

Predefined color. (0xFFFFFF)

◆ yellow

const Color Util::Color::yellow = Color(0xFFFFFF00)
static

Predefined color. (0xFFFF00)


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