JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Rgba.hpp
Go to the documentation of this file.
1// Copyright 2024 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 "Rgb.hpp"
8
9#include <cstdint>
10
11namespace jngl {
12class Alpha;
13
22class Rgba {
23public:
30 Rgba(float red, float green, float blue, float alpha);
31 Rgba(float red, float green, float blue, Alpha alpha);
32 Rgba(Rgb, Alpha);
33
34 static Rgba u8(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
35
37 float getRed() const;
39 void setRed(float);
40
42 float getGreen() const;
44 void setGreen(float);
45
47 float getBlue() const;
49 void setBlue(float);
50
52 float getAlpha() const;
54 void setAlpha(float);
55 void setAlpha(Alpha);
56
58 void setRgb(Rgb color);
59
61 explicit operator Rgb() const;
62
63private:
64 float red;
65 float green;
66 float blue;
67 float alpha;
68};
69
71Rgba interpolate(Rgba a, Rgba b, float t);
72
73} // namespace jngl
74
76jngl::Rgba operator"" _rgba(unsigned long long);
Contains jngl::Rgb class.
Object representing only the Alpha Channel in an RGBA color.
Definition Alpha.hpp:11
Object representing a RGB color, new version of jngl::Color (which will be deprecated in the future)
Definition Rgb.hpp:15
Object representing a RGBA color.
Definition Rgba.hpp:22
void setRgb(Rgb color)
Overwrites red, green and blue, but leaves the alpha value untouched.
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
float getAlpha() const
0.0f ... 1.0f
Rgba(float red, float green, float blue, float alpha)
void setGreen(float)
0.0f ... 1.0f
float getBlue() const
0.0f ... 1.0f
void setAlpha(float)
0.0f ... 1.0f
JNGL's main namespace.
Color interpolate(Color a, Color b, float t)
Returns a color mix between a (t == 0) and b (t == 1)