Gamedev Framework (gf)  0.10.0
A C++14 framework for 2D games
Public Types | Public Member Functions | List of all members
gf::ConsoleEffect Class Reference

A console effect on the background color. More...

#include <gf/Console.h>

Public Types

enum  Kind : uint32_t {
  None,
  Set,
  Multiply,
  Lighten,
  Darken,
  Screen,
  ColorDodge,
  ColorBurn,
  Add,
  AddAlpha,
  Burn,
  Overlay,
  Alpha,
  Default
}
 The kind of console effect. More...
 

Public Member Functions

constexpr ConsoleEffect (Kind kind)
 Constructor with a kind only. More...
 
constexpr ConsoleEffect (Kind kind, float alpha)
 Constructor with a kind and \( \alpha \). More...
 
constexpr Kind getKind () const noexcept
 Get the kind of effect. More...
 
constexpr bool isDefault () const noexcept
 Check if the effect if Console::Default. More...
 
constexpr float getAlpha () const noexcept
 Get the alpha value. More...
 

Detailed Description

A console effect on the background color.

A console effect is used to modify the background color of the console.

If \( \textbf{b} \) is the current background color, and \( \textbf{c} \) is the wanted color, then the result color \( \textbf{r} \) is given by the following description. Note that ConsoleEffect::AddAlpha and ConsoleEffect::Alpha need an \( \alpha \) value.

See also
gf::Console

Member Enumeration Documentation

◆ Kind

enum gf::ConsoleEffect::Kind : uint32_t

The kind of console effect.

Enumerator
None 

Do not change the background color.

Set 

\[ \textbf{r} = \textbf{c} \]

Multiply 

\[ \textbf{r} = \textbf{b} \cdot \textbf{c} \]

Lighten 

\[ \textbf{r} = \max(\textbf{b}, \textbf{c}) \]

Darken 

\[ \textbf{r} = \min(\textbf{b}, \textbf{c}) \]

Screen 

\[ \textbf{r} = 1 - (1 - \textbf{b}) \cdot (1 - \textbf{c}) \]

ColorDodge 

\[ \textbf{r} = \frac{\textbf{c}}{1 - \textbf{b}} \]

ColorBurn 

\[ \textbf{r} = 1 - \frac{1 - \textbf{b}}{\textbf{c}} \]

Add 

\[ \textbf{r} = \textbf{b} + \textbf{c} \]

AddAlpha 

\[ \textbf{r} = \textbf{b} + \alpha \cdot \textbf{c} \]

Burn 

\[ \textbf{r} = \textbf{b} + \textbf{c} - 1 \]

Overlay 

\[ \textbf{r} = \begin{cases} 2 \cdot \textbf{b} \cdot \textbf{c} & \text{if } \textbf{b} \leq 0.5 \\ 1 - 2 \cdot (1 - \textbf{b}) \cdot (1 - \textbf{c}) & \text{otherwise} \end{cases} \]

Alpha 

\[ \textbf{r} = (1 - \alpha) \cdot \textbf{b} + \alpha \cdot \textbf{c} \]

Default 

Use the default console effect.

Constructor & Destructor Documentation

◆ ConsoleEffect() [1/2]

constexpr gf::ConsoleEffect::ConsoleEffect ( Kind  kind)
inline

Constructor with a kind only.

This constructor sould be used with all the effects, except ConsoleEffect::AddAlpha and ConsoleEffect::Alpha.

Parameters
kindThe kind of effect

◆ ConsoleEffect() [2/2]

constexpr gf::ConsoleEffect::ConsoleEffect ( Kind  kind,
float  alpha 
)
inline

Constructor with a kind and \( \alpha \).

This constructor should be used with ConsoleEffect::AddAlpha and ConsoleEffect::Alpha.

Parameters
kindThe kind of effect
alphaThe \( \alpha \) value

Member Function Documentation

◆ getAlpha()

constexpr float gf::ConsoleEffect::getAlpha ( ) const
inlinenoexcept

Get the alpha value.

◆ getKind()

constexpr Kind gf::ConsoleEffect::getKind ( ) const
inlinenoexcept

Get the kind of effect.

◆ isDefault()

constexpr bool gf::ConsoleEffect::isDefault ( ) const
inlinenoexcept

Check if the effect if Console::Default.