Plasma Engine  2.0
Loading...
Searching...
No Matches
plColorGradient Class Reference

A color curve for animating colors. More...

#include <ColorGradient.h>

Classes

struct  AlphaCP
 Alpha control point. More...
 
struct  ColorCP
 Color control point. Stores red, green and blue in gamma space. More...
 
struct  IntensityCP
 Intensity control point. Used to scale rgb for high-dynamic range values. More...
 

Public Member Functions

void Clear ()
 Removes all control points.
 
bool IsEmpty () const
 Checks whether the curve has any control point.
 
void AddColorControlPoint (double x, const plColorGammaUB &rgb)
 Appends a color control point. SortControlPoints() must be called to before evaluating the curve.
 
void AddAlphaControlPoint (double x, plUInt8 uiAlpha)
 Appends an alpha control point. SortControlPoints() must be called to before evaluating the curve.
 
void AddIntensityControlPoint (double x, float fIntensity)
 Appends an intensity control point. SortControlPoints() must be called to before evaluating the curve.
 
bool GetExtents (double &ref_fMinx, double &ref_fMaxx) const
 Determines the min and max x-coordinate value across all control points.
 
void GetNumControlPoints (plUInt32 &ref_uiRgb, plUInt32 &ref_uiAlpha, plUInt32 &ref_uiIntensity) const
 Returns the number of control points of each type.
 
const ColorCPGetColorControlPoint (plUInt32 uiIdx) const
 Const access to a control point.
 
const AlphaCPGetAlphaControlPoint (plUInt32 uiIdx) const
 Const access to a control point.
 
const IntensityCPGetIntensityControlPoint (plUInt32 uiIdx) const
 Const access to a control point.
 
ColorCPModifyColorControlPoint (plUInt32 uiIdx)
 Non-const access to a control point. If you modify the x coordinate, SortControlPoints() has to be called before evaluating the curve.
 
AlphaCPModifyAlphaControlPoint (plUInt32 uiIdx)
 Non-const access to a control point. If you modify the x coordinate, SortControlPoints() has to be called before evaluating the curve.
 
IntensityCPModifyIntensityControlPoint (plUInt32 uiIdx)
 Non-const access to a control point. If you modify the x coordinate, SortControlPoints() has to be called before evaluating the curve.
 
void SortControlPoints ()
 Sorts the control point arrays by their x-coordinate. The CPs have to be sorted before calling Evaluate(), otherwise the result will be wrong.
 
void Evaluate (double x, plColorGammaUB &ref_rgba, float &ref_fIntensity) const
 Evaluates the curve at the given x-coordinate and returns RGBA and intensity separately.
 
void Evaluate (double x, plColor &ref_hdr) const
 Evaluates the curve and returns RGBA and intensity in one combined plColor value.
 
void EvaluateColor (double x, plColorGammaUB &ref_rgb) const
 Evaluates only the color curve.
 
void EvaluateColor (double x, plColor &ref_rgb) const
 Evaluates only the color curve.
 
void EvaluateAlpha (double x, plUInt8 &ref_uiAlpha) const
 Evaluates only the alpha curve.
 
void EvaluateIntensity (double x, float &ref_fIntensity) const
 Evaluates only the intensity curve.
 
plUInt64 GetHeapMemoryUsage () const
 How much heap memory the curve uses.
 
void Save (plStreamWriter &inout_stream) const
 Stores the current state in a stream.
 
void Load (plStreamReader &inout_stream)
 Restores the state from a stream.
 

Detailed Description

A color curve for animating colors.

The gradient consists of a number of control points, for rgb, alpha and intensity. One can evaluate the curve at any x coordinate.

Member Function Documentation

◆ Evaluate()

void plColorGradient::Evaluate ( double x,
plColorGammaUB & ref_rgba,
float & ref_fIntensity ) const

Evaluates the curve at the given x-coordinate and returns RGBA and intensity separately.

The control points have to be sorted, so call SortControlPoints() before, if any modifications where done.

◆ EvaluateAlpha()

void plColorGradient::EvaluateAlpha ( double x,
plUInt8 & ref_uiAlpha ) const

Evaluates only the alpha curve.

Todo
Use a midpoint interpolation

◆ EvaluateColor()

void plColorGradient::EvaluateColor ( double x,
plColor & ref_rgb ) const

Evaluates only the color curve.

Todo
Use a midpoint interpolation

◆ EvaluateIntensity()

void plColorGradient::EvaluateIntensity ( double x,
float & ref_fIntensity ) const

Evaluates only the intensity curve.

Todo
Use a midpoint interpolation

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