JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Rgba Class Reference

Object representing a RGBA color. More...

#include <jngl/Rgba.hpp>

Public Member Functions

constexpr Rgba (float red, float green, float blue, float alpha)
 
 Rgba (float red, float green, float blue, Alpha alpha)
 
 Rgba (Rgb, Alpha)
 
constexpr float getRed () const
 0.0f ... 1.0f
 
void setRed (float)
 0.0f ... 1.0f
 
constexpr float getGreen () const
 0.0f ... 1.0fu
 
void setGreen (float)
 0.0f ... 1.0f
 
constexpr float getBlue () const
 0.0f ... 1.0f
 
void setBlue (float)
 0.0f ... 1.0f
 
constexpr float getAlpha () const
 0.0f ... 1.0f
 
void setAlpha (float)
 0.0f ... 1.0f
 
void setAlpha (Alpha)
 
void setRgb (Rgb color)
 Overwrites red, green and blue, but leaves the alpha value untouched.
 
 operator Rgb () const
 Drops the alpha value.
 

Static Public Member Functions

static constexpr Rgba u8 (uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
 

Detailed Description

Object representing a RGBA color.

You can use the custom literal operator to create jngl::Rgba from HTML color codes. For example #68da4fee becomes:

jngl::Rgba color = 0x68da4fee_rgba;
Object representing a RGBA color.
Definition Rgba.hpp:22

Definition at line 22 of file Rgba.hpp.

Constructor & Destructor Documentation

◆ Rgba()

Rgba ( float red,
float green,
float blue,
float alpha )
inlineconstexpr
Parameters
red0.0f ... 1.0f
green0.0f ... 1.0f
blue0.0f ... 1.0f
alpha0.0f ... 1.0f

Values over 1.0f will result in 1.0f and negatives will result in 0.0f.

Definition at line 30 of file Rgba.hpp.

Member Function Documentation

◆ u8()

static constexpr Rgba u8 ( uint8_t red,
uint8_t green,
uint8_t blue,
uint8_t alpha )
inlinestaticconstexpr

Definition at line 36 of file Rgba.hpp.

◆ getRed()

float getRed ( ) const
inlineconstexpr

0.0f ... 1.0f

Definition at line 42 of file Rgba.hpp.

◆ getGreen()

float getGreen ( ) const
inlineconstexpr

0.0f ... 1.0fu

Definition at line 49 of file Rgba.hpp.

◆ getBlue()

float getBlue ( ) const
inlineconstexpr

0.0f ... 1.0f

Definition at line 56 of file Rgba.hpp.

◆ getAlpha()

float getAlpha ( ) const
inlineconstexpr

0.0f ... 1.0f

Definition at line 63 of file Rgba.hpp.


The documentation for this class was generated from the following file: