PhoenixPNG  0.1.0
Set of tools to ease use of png file
Loading...
Searching...
No Matches
PColorMap Class Reference

Describe a color map to adapt color with input value. More...

#include <PColorMap.h>

Public Member Functions

void addColor (float value, color_t red, color_t green, color_t blue, color_t alpha=255)
 Add a color in the PColorMap.
 
void addColor (float value, const PString &color)
 Add a color in the PColorMap.
 
void interpolate (color_t &red, color_t &green, color_t &blue, color_t &alpha, float value) const
 Interpolate color by respect to the given value.
 
void interpolate (color_t &red, color_t &green, color_t &blue, float value) const
 Interpolate color by respect to the given value.
 
void interpolate (PColorValue &output, float value) const
 Interpolate color by respect to the given value.
 
PColorMapoperator= (const PColorMap &other)
 Definition of equal operator of PColorMap.
 
 PColorMap ()
 Default constructor of PColorMap.
 
 PColorMap (const PColorMap &other)
 Copy constructor of PColorMap.
 
virtual ~PColorMap ()
 Destructor of PColorMap.
 

Protected Member Functions

void copyPColorMap (const PColorMap &other)
 Copy function of PColorMap.
 

Private Member Functions

void initialisationPColorMap ()
 Initialisation function of the class PColorMap.
 

Private Attributes

PMapColorValue p_mapColor
 Vector of the value.
 

Detailed Description

Describe a color map to adapt color with input value.

Definition at line 38 of file PColorMap.h.

Constructor & Destructor Documentation

◆ PColorMap() [1/2]

PColorMap::PColorMap ( )

Default constructor of PColorMap.

Definition at line 97 of file PColorMap.cpp.

97 {
99}
void initialisationPColorMap()
Initialisation function of the class PColorMap.

References initialisationPColorMap().

Referenced by copyPColorMap(), operator=(), and PColorMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PColorMap() [2/2]

PColorMap::PColorMap ( const PColorMap & other)

Copy constructor of PColorMap.

Parameters
other: class to copy

Definition at line 104 of file PColorMap.cpp.

104 {
105 copyPColorMap(other);
106}
void copyPColorMap(const PColorMap &other)
Copy function of PColorMap.

References copyPColorMap(), and PColorMap().

+ Here is the call graph for this function:

◆ ~PColorMap()

PColorMap::~PColorMap ( )
virtual

Destructor of PColorMap.

Definition at line 109 of file PColorMap.cpp.

109 {
110
111}

Member Function Documentation

◆ addColor() [1/2]

void PColorMap::addColor ( float value,
color_t red,
color_t green,
color_t blue,
color_t alpha = 255 )

Add a color in the PColorMap.

Parameters
value: associated value with the given color
red: red proportion
green: green proportion
blue: blue proportion
alpha: transparent proportion

Definition at line 138 of file PColorMap.cpp.

138 {
139 PColorValue colorValue = createColorValue(value, red, green, blue, alpha);
140 p_mapColor[value] = colorValue;
141}
PColorValue createColorValue(float value, const PString &color)
Create a PColorValue.
Definition PColorMap.cpp:15
PMapColorValue p_mapColor
Vector of the value.
Definition PColorMap.h:58

References createColorValue(), and p_mapColor.

+ Here is the call graph for this function:

◆ addColor() [2/2]

void PColorMap::addColor ( float value,
const PString & color )

Add a color in the PColorMap.

Parameters
value: associated value with the given color
color: hexadecimal color associated to the given value (FF000000, 00FF0000, 0000FF00, 000000FF, etc)

Definition at line 126 of file PColorMap.cpp.

126 {
127 PColorValue colorValue = createColorValue(value, color);
128 p_mapColor[value] = colorValue;
129}

References createColorValue(), and p_mapColor.

+ Here is the call graph for this function:

◆ copyPColorMap()

void PColorMap::copyPColorMap ( const PColorMap & other)
protected

Copy function of PColorMap.

Parameters
other: class to copy

Definition at line 204 of file PColorMap.cpp.

204 {
205 p_mapColor = other.p_mapColor;
206}

References p_mapColor, and PColorMap().

Referenced by operator=(), and PColorMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initialisationPColorMap()

void PColorMap::initialisationPColorMap ( )
private

Initialisation function of the class PColorMap.

Definition at line 209 of file PColorMap.cpp.

209 {
210
211}

Referenced by PColorMap().

+ Here is the caller graph for this function:

◆ interpolate() [1/3]

void PColorMap::interpolate ( color_t & red,
color_t & green,
color_t & blue,
color_t & alpha,
float value ) const

Interpolate color by respect to the given value.

Parameters
[out]red: red proportion
[out]green: green proportion
[out]blue: blue proportion
[out]alpha: transparent proportion
value: given value

Definition at line 164 of file PColorMap.cpp.

164 {
165 PColorValue out;
166 interpolate(out, value);
167 red = out.r;
168 green = out.g;
169 blue = out.b;
170 alpha = out.a;
171}
void interpolate(color_t &red, color_t &green, color_t &blue, float value) const
Interpolate color by respect to the given value.
color_t r
Red channel.
Definition PColorMap.h:21
color_t g
Green channel.
Definition PColorMap.h:23
color_t a
Alpha channel.
Definition PColorMap.h:27
color_t b
Blue channel.
Definition PColorMap.h:25

References PColorValue::a, PColorValue::b, PColorValue::g, interpolate(), and PColorValue::r.

+ Here is the call graph for this function:

◆ interpolate() [2/3]

void PColorMap::interpolate ( color_t & red,
color_t & green,
color_t & blue,
float value ) const

Interpolate color by respect to the given value.

Parameters
[out]red: red proportion
[out]green: green proportion
[out]blue: blue proportion
value: given value

Definition at line 149 of file PColorMap.cpp.

149 {
150 PColorValue out;
151 interpolate(out, value);
152 red = out.r;
153 green = out.g;
154 blue = out.b;
155}

References PColorValue::b, PColorValue::g, interpolate(), and PColorValue::r.

Referenced by interpolate(), interpolate(), and PImagePng::setColor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ interpolate() [3/3]

void PColorMap::interpolate ( PColorValue & output,
float value ) const

Interpolate color by respect to the given value.

Parameters
[out]output: output color
value: given value

Definition at line 177 of file PColorMap.cpp.

177 {
178 if(p_mapColor.size() == 0lu){return;} //No color
179 PMapColorValue::const_iterator itMin(p_mapColor.begin());
180 if(value <= itMin->second.value){ //If the value is smaller than the first colored one
181 output = itMin->second; //We copy this value
182 return;
183 }
184 PMapColorValue::const_reverse_iterator rit(p_mapColor.rbegin());
185 if(value >= rit->second.value){ //If the value is greater than the last colored one
186 output = rit->second; //We copy this value
187 return;
188 }
189 PMapColorValue::const_iterator itMax(itMin);
190 ++itMax;
191 while(itMax != p_mapColor.end()){
192 if(value > itMin->second.value && value < itMax->second.value){
193 phoenix_interpolateColor(output, itMin->second, itMax->second, value);
194 break;
195 }
196 ++itMax;
197 ++itMin;
198 }
199}
void phoenix_interpolateColor(PColorValue &output, const PColorValue &colorMin, const PColorValue &colorMax, float value)
Interpolate a color with a value by respect to min an max color.
Definition PColorMap.cpp:75

References p_mapColor, and phoenix_interpolateColor().

+ Here is the call graph for this function:

◆ operator=()

PColorMap & PColorMap::operator= ( const PColorMap & other)

Definition of equal operator of PColorMap.

Parameters
other: class to copy
Returns
copied class

Definition at line 117 of file PColorMap.cpp.

117 {
118 copyPColorMap(other);
119 return *this;
120}

References copyPColorMap(), and PColorMap().

+ Here is the call graph for this function:

Member Data Documentation

◆ p_mapColor

PMapColorValue PColorMap::p_mapColor
private

Vector of the value.

Definition at line 58 of file PColorMap.h.

Referenced by addColor(), addColor(), copyPColorMap(), and interpolate().


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