arsa  2.7
Public Member Functions | Public Attributes | List of all members
irr::video::SColorf Class Reference

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

#include <SColor.h>

Public Member Functions

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

Public Attributes

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

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.

Definition at line 573 of file SColor.h.

Constructor & Destructor Documentation

◆ SColorf() [1/3]

irr::video::SColorf::SColorf ( )
inline

Default constructor for SColorf.

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

Definition at line 578 of file SColor.h.

578 : r(0.0f), g(0.0f), b(0.0f), a(1.0f) {}
f32 b
blue component
Definition: SColor.h:695
f32 g
green color component
Definition: SColor.h:692
f32 a
alpha color component
Definition: SColor.h:698
GLfloat f
f32 r
red color component
Definition: SColor.h:689

◆ SColorf() [2/3]

irr::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.

Definition at line 591 of file SColor.h.

591 : r(r), g(g), b(b), a(a) {}
f32 b
blue component
Definition: SColor.h:695
f32 g
green color component
Definition: SColor.h:692
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
f32 a
alpha color component
Definition: SColor.h:698
GLboolean GLboolean GLboolean b
f32 r
red color component
Definition: SColor.h:689
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g

◆ SColorf() [3/3]

irr::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.

Definition at line 596 of file SColor.h.

597  {
598  const f32 inv = 1.0f / 255.0f;
599  r = c.getRed() * inv;
600  g = c.getGreen() * inv;
601  b = c.getBlue() * inv;
602  a = c.getAlpha() * inv;
603  }
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
const GLubyte * c
GLboolean GLboolean g

Member Function Documentation

◆ getAlpha()

f32 irr::video::SColorf::getAlpha ( ) const
inline

Returns the alpha component of the color in the range 0.0 (transparent) to 1.0 (opaque)

Definition at line 677 of file SColor.h.

677 { return a; }
f32 a
alpha color component
Definition: SColor.h:698

◆ getBlue()

f32 irr::video::SColorf::getBlue ( ) const
inline

Returns the blue component of the color in the range 0.0 to 1.0.

Definition at line 686 of file SColor.h.

686 { return b; }
f32 b
blue component
Definition: SColor.h:695

◆ getGreen()

f32 irr::video::SColorf::getGreen ( ) const
inline

Returns the green component of the color in the range 0.0 to 1.0.

Definition at line 683 of file SColor.h.

683 { return g; }
f32 g
green color component
Definition: SColor.h:692

◆ getInterpolated()

SColorf irr::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.

Definition at line 635 of file SColor.h.

636  {
637  d = core::clamp(d, 0.f, 1.f);
638  const f32 inv = 1.0f - d;
639  return SColorf(other.r*inv + r*d,
640  other.g*inv + g*d, other.b*inv + b*d, other.a*inv + a*d);
641  }
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
GLfloat f
GLboolean GLboolean GLboolean b
SColorf()
Default constructor for SColorf.
Definition: SColor.h:578
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition: irrMath.h:167

◆ getInterpolated_quadratic()

SColorf irr::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.

Definition at line 647 of file SColor.h.

649  {
650  d = core::clamp(d, 0.f, 1.f);
651  // this*(1-d)*(1-d) + 2 * c1 * (1-d) + c2 * d * d;
652  const f32 inv = 1.f - d;
653  const f32 mul0 = inv * inv;
654  const f32 mul1 = 2.f * d * inv;
655  const f32 mul2 = d * d;
656 
657  return SColorf (r * mul0 + c1.r * mul1 + c2.r * mul2,
658  g * mul0 + c1.g * mul1 + c2.g * mul2,
659  b * mul0 + c1.b * mul1 + c2.b * mul2,
660  a * mul0 + c1.a * mul1 + c2.a * mul2);
661  }
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
GLfloat f
GLboolean GLboolean GLboolean b
SColorf()
Default constructor for SColorf.
Definition: SColor.h:578
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition: irrMath.h:167

◆ getRed()

f32 irr::video::SColorf::getRed ( ) const
inline

Returns the red component of the color in the range 0.0 to 1.0.

Definition at line 680 of file SColor.h.

680 { return r; }
f32 r
red color component
Definition: SColor.h:689

◆ set() [1/2]

void irr::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.

Definition at line 618 of file SColor.h.

618 {r = rr; g =gg; b = bb; }
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
GLboolean GLboolean GLboolean b
GLboolean GLboolean g

◆ set() [2/2]

void irr::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.

Definition at line 629 of file SColor.h.

629 {a = aa; r = rr; g =gg; b = bb; }
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g

◆ setColorComponentValue()

void irr::video::SColorf::setColorComponentValue ( s32  index,
f32  value 
)
inline

Sets a color component by index. R=0, G=1, B=2, A=3.

Definition at line 665 of file SColor.h.

666  {
667  switch(index)
668  {
669  case 0: r = value; break;
670  case 1: g = value; break;
671  case 2: b = value; break;
672  case 3: a = value; break;
673  }
674  }
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
GLsizei const GLfloat * value
GLuint index
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g

◆ toSColor()

SColor irr::video::SColorf::toSColor ( ) const
inline

Converts this color to a SColor without floats.

Definition at line 606 of file SColor.h.

607  {
608  return SColor((u32)core::round32(a*255.0f), (u32)core::round32(r*255.0f), (u32)core::round32(g*255.0f), (u32)core::round32(b*255.0f));
609  }
REALINLINE s32 round32(f32 x)
Definition: irrMath.h:657
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
GLfloat f
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean g

Member Data Documentation

◆ a

f32 irr::video::SColorf::a

alpha color component

Definition at line 698 of file SColor.h.

◆ b

f32 irr::video::SColorf::b

blue component

Definition at line 695 of file SColor.h.

◆ g

f32 irr::video::SColorf::g

green color component

Definition at line 692 of file SColor.h.

◆ r

f32 irr::video::SColorf::r

red color component

Definition at line 689 of file SColor.h.


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