Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
nirt::video::SColorf Class Reference

Class representing a color with four floats. More...

#include <nirtcpp/core/engine/SColor.hpp>

Public Member Functions

 SColorf ()
 Default constructor for SColorf.
 
 SColorf (f32 r, f32 g, f32 b, f32 a=1.0f)
 Constructs a color from up to four color values: red, green, blue, and alpha.
 
 SColorf (SColor c)
 Constructs a color from 32 bit Color.
 
SColor toSColor () const
 Converts this color to a SColor without floats.
 
void set (f32 rr, f32 gg, f32 bb)
 Sets three color components to new values at once.
 
void set (f32 aa, f32 rr, f32 gg, f32 bb)
 Sets all four color components to new values at once.
 
SColorf getInterpolated (const SColorf &other, f32 d) const
 Interpolates the color with a f32 value to another color.
 
SColorf getInterpolated_quadratic (const SColorf &c1, const SColorf &c2, f32 d) const
 Returns interpolated color. ( quadratic )
 
void setColorComponentValue (s32 index, f32 value)
 Sets a color component by index. R=0, G=1, B=2, A=3.
 
f32 getAlpha () const
 Returns the alpha component of the color in the range 0.0 (transparent) to 1.0 (opaque)
 
f32 getRed () const
 Returns the red component of the color in the range 0.0 to 1.0.
 
f32 getGreen () const
 Returns the green component of the color in the range 0.0 to 1.0.
 
f32 getBlue () const
 Returns the blue component of the color in the range 0.0 to 1.0.
 

Public Attributes

f32 r
 red color component
 
f32 g
 green color component
 
f32 b
 blue component
 
f32 a
 alpha color component
 

Detailed Description

Class representing a color with four floats.

The color values for red, green, blue and alpha are each stored in a 32 bit floating point variable. So all four values may be between 0.0f and 1.0f. Another, faster way to define colors is using the class SColor, which stores the color values in a single 32 bit integer.

Constructor & Destructor Documentation

◆ SColorf() [1/3]

nirt::video::SColorf::SColorf ( )
inline

Default constructor for SColorf.

Sets red, green and blue to 0.0f and alpha to 1.0f.

◆ SColorf() [2/3]

nirt::video::SColorf::SColorf ( f32  r,
f32  g,
f32  b,
f32  a = 1.0f 
)
inline

Constructs a color from up to four color values: red, green, blue, and alpha.

Parameters
rRed color component. Should be a value between 0.0f meaning no red and 1.0f, meaning full red.
gGreen color component. Should be a value between 0.0f meaning no green and 1.0f, meaning full green.
bBlue color component. Should be a value between 0.0f meaning no blue and 1.0f, meaning full blue.
aAlpha color component of the color. The alpha component defines how transparent a color should be. Has to be a value between 0.0f and 1.0f, 1.0f means not transparent (opaque), 0.0f means fully transparent.

◆ SColorf() [3/3]

nirt::video::SColorf::SColorf ( SColor  c)
inline

Constructs a color from 32 bit Color.

Parameters
c32 bit color from which this SColorf class is constructed from.

Member Function Documentation

◆ getInterpolated()

SColorf nirt::video::SColorf::getInterpolated ( const SColorf other,
f32  d 
) const
inline

Interpolates the color with a f32 value to another color.

Parameters
otherOther color
dvalue between 0.0f and 1.0f
Returns
Interpolated color.

◆ getInterpolated_quadratic()

SColorf nirt::video::SColorf::getInterpolated_quadratic ( const SColorf c1,
const SColorf c2,
f32  d 
) const
inline

Returns interpolated color. ( quadratic )

Parameters
c1first color to interpolate with
c2second color to interpolate with
dvalue between 0.0f and 1.0f.

◆ set() [1/2]

void nirt::video::SColorf::set ( f32  aa,
f32  rr,
f32  gg,
f32  bb 
)
inline

Sets all four color components to new values at once.

Parameters
aaAlpha component. Should be a value between 0.0f meaning fully transparent and 1.0f, meaning opaque.
rrRed color component. Should be a value between 0.0f meaning no red and 1.0f, meaning full red.
ggGreen color component. Should be a value between 0.0f meaning no green and 1.0f, meaning full green.
bbBlue color component. Should be a value between 0.0f meaning no blue and 1.0f, meaning full blue.

◆ set() [2/2]

void nirt::video::SColorf::set ( f32  rr,
f32  gg,
f32  bb 
)
inline

Sets three color components to new values at once.

Parameters
rrRed color component. Should be a value between 0.0f meaning no red (=black) and 1.0f, meaning full red.
ggGreen color component. Should be a value between 0.0f meaning no green (=black) and 1.0f, meaning full green.
bbBlue color component. Should be a value between 0.0f meaning no blue (=black) and 1.0f, meaning full blue.

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

Nirtcpp    @cppfx.xyz

Utxcpp    utx::print