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(Rgb, Alpha);
32
33 static Rgba u8(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
34
36 float getRed() const;
38 void setRed(float);
39
41 float getGreen() const;
43 void setGreen(float);
44
46 float getBlue() const;
48 void setBlue(float);
49
51 float getAlpha() const;
53 void setAlpha(float);
54 void setAlpha(Alpha);
55
57 void setRgb(Rgb color);
58
60 explicit operator Rgb() const;
61
62private:
63 float red;
64 float green;
65 float blue;
66 float alpha;
67};
68
70Rgba interpolate(Rgba a, Rgba b, float t);
71
72} // namespace jngl
73
75jngl::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:12
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.
Definition: Achievement.hpp:10
Color interpolate(Color a, Color b, float t)
Returns a color mix between a (t == 0) and b (t == 1)