JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Rgb.hpp
Go to the documentation of this file.
1// Copyright 2024-2025 Jan Niklas Hasse <jhasse@bixense.com>
2// For conditions of distribution and use, see copyright notice in LICENSE.txt
5#pragma once
6
7#include <cstdint>
8#include <iosfwd>
9
10namespace jngl {
11
12class Color;
13
16class Rgb {
17public:
23 Rgb(float red, float green, float blue);
24
25 static Rgb u8(uint8_t red, uint8_t green, uint8_t blue);
26
28 Rgb(Color); // NOLINT
29
31 float getRed() const;
33 void setRed(float);
34
36 float getGreen() const;
38 void setGreen(float);
39
41 float getBlue() const;
43 void setBlue(float);
44
46 uint8_t getRed_u8() const;
47
49 uint8_t getGreen_u8() const;
50
52 uint8_t getBlue_u8() const;
53
55 explicit operator Color() const;
56
57private:
58 float red;
59 float green;
60 float blue;
61};
62
64Rgb interpolate(Rgb a, Rgb b, float t);
65
68bool operator==(Rgb a, Rgb b);
69
72
73} // namespace jngl
74
76jngl::Rgb operator""_rgb(unsigned long long);
Object representing a RGB color.
Definition Color.hpp:28
Object representing a RGB color, new version of jngl::Color (which will be deprecated in the future)
Definition Rgb.hpp:16
uint8_t getGreen_u8() const
0 ... 255
Rgb(float red, float green, float blue)
uint8_t getRed_u8() const
0 ... 255
void setBlue(float)
0.0f ... 1.0f
float getRed() const
0.0f ... 1.0f
float getGreen() const
0.0f ... 1.0fu
void setRed(float)
0.0f ... 1.0f
void setGreen(float)
0.0f ... 1.0f
Rgb(Color)
Implicit conversion for backwards compatibility.
float getBlue() const
0.0f ... 1.0f
uint8_t getBlue_u8() const
0 ... 255
JNGL's main namespace.
Color interpolate(Color a, Color b, float t)
Returns a color mix between a (t == 0) and b (t == 1)
bool operator==(Rgb a, Rgb b)
Returns true if the two colors are equal in 24 bit SDR space, i.e.
std::ostream & operator<<(std::ostream &os, Rgb color)
Prints the color as jngl::Rgb{ red, green, blue }