Nebula
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
11#include "core/types.h"
12#include "math/vec4.h"
13
14//------------------------------------------------------------------------------
15namespace Util
16{
17class Color : public Math::vec4
18{
19 public:
20 Color() = default;
21 Color(const Color& c) = default;
23 Color(float r, float g, float b, float a);
25 Color(const Math::vec4& v);
27 Color(const Math::vec3& v);
29 Color(uint32_t argb);
31 Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
32};
33
34//------------------------------------------------------------------------------
37__forceinline
38Color::Color(float r, float g, float b, float a) : Math::vec4(r,g,b,a)
39{
40}
41
42//------------------------------------------------------------------------------
45__forceinline
47{
48}
49
50//------------------------------------------------------------------------------
53__forceinline
54Color::Color(const Math::vec3& v) : Math::vec4(v,1.0f)
55{
56}
57
58//------------------------------------------------------------------------------
61__forceinline
62Color::Color(uint32_t argb)
63{
64 const float scale = 1.0f / 255.0f;
65 this->vec = _mm_setr_ps(scale * ((argb >> 16) & 0xFF), scale * ((argb >> 8) & 0xFF), scale * (argb & 0xFF), scale * ((argb >> 24) & 0xFF));
66}
67//------------------------------------------------------------------------------
70__forceinline
71Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
72{
73 const float scale = 1.0f / 255.0f;
74 this->vec = _mm_setr_ps(scale * r, scale * g, scale * b, scale * a);
75}
76}
For now just a wrapper around Math::vec4 for type safety.
Definition color.h:18
Color()=default
Color(const Color &c)=default
Different curves.
Definition angularpfeedbackloop.h:17
A pinned array is an array which manages its own virtual memory.
Definition String.cs:6
A 3D vector.
Definition vec3.h:40
A 4D vector.
Definition vec4.h:24
__m128 vec
Definition vec4.h:95
float v[4]
Definition vec4.h:96