cangine
Loading...
Searching...
No Matches
color.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cassert>
4
5namespace cangine {
12 struct Color {
13 float r = 0;
14 float g = 0;
15 float b = 0;
16 float a = 0;
17
19 inline Color() : Color(255, 255, 255, 1) {};
20
28 inline Color(float r, float g, float b, float a) {
29 assert(a >= 0.0f && a <= 1.0f);
30
31 this->r = r / 255.0f;
32 this->g = g / 255.0f;
33 this->b = b / 255.0f;
34 this->a = a;
35 };
42 inline Color(float r, float g, float b) : Color(r, g, b, 1.0f) {};
43
44 };
45
47 namespace Colors {
48 inline const Color BLACK(0, 0, 0);
49 inline const Color WHITE(255, 255, 255);
50 inline const Color GRAY(128, 128, 128);
51 inline const Color DARK_GRAY(99, 99, 99);
52 inline const Color RED(255, 0, 0);
53 inline const Color GREEN(0, 255, 0);
54 inline const Color BLUE(0, 0, 255);
55 }
56}
const Color RED(255, 0, 0)
Pure red.
const Color WHITE(255, 255, 255)
White.
const Color BLUE(0, 0, 255)
Pure blue.
const Color GREEN(0, 255, 0)
Pure green.
const Color DARK_GRAY(99, 99, 99)
Dark gray.
const Color GRAY(128, 128, 128)
Medium gray.
const Color BLACK(0, 0, 0)
Black.
Definition audiomanager.cpp:4
RGBA color stored as normalized floating-point components.
Definition color.hpp:12
Color(float r, float g, float b, float a)
Constructs a color from 0-255 RGB values and an alpha.
Definition color.hpp:28
Color()
Constructs an opaque white color.
Definition color.hpp:19
float r
Red channel, normalized to [0, 1].
Definition color.hpp:13
float a
Alpha channel in [0, 1].
Definition color.hpp:16
Color(float r, float g, float b)
Constructs a fully opaque color from 0-255 RGB values.
Definition color.hpp:42
float b
Blue channel, normalized to [0, 1].
Definition color.hpp:15
float g
Green channel, normalized to [0, 1].
Definition color.hpp:14