Simple++
Powerfull and lightning fast C++ Library
Public Member Functions | Static Public Member Functions | List of all members
Graphic::GradientLinear< C, InterFunc > Class Template Reference

#include <Gradient.h>

Inheritance diagram for Graphic::GradientLinear< C, InterFunc >:
Graphic::Gradient< C, InterFunc >

Public Member Functions

 GradientLinear (float angle, const Math::Vec2< float > &p=Math::Vec2< float >::null, unsigned int length=0, const InterFunc &functor=InterFunc())
 Create a new Linear Gradient. More...
 
void setAngle (float angle)
 set the angle of this linear gradient More...
 
void setPoint (const Math::Vec2< float > &p)
 set the starting point of this gradient More...
 
void setLength (unsigned int length)
 
float getAngle () const
 get the angle of this gradient More...
 
float getAngleRad () const
 get the angle of this gradient More...
 
const Math::Vec2< float > & getPoint () const
 get the point of this gradient More...
 
unsigned int getLength () const
 get the length of this gradient More...
 
const Math::Vec2< float > & getDirection () const
 get the unitary vector representing the direction of this gradient. More...
 
int computeIndex (const Math::Vec2< float > &p, int maxIndex) const
 Compute the index in the interpolated array. More...
 
- Public Member Functions inherited from Graphic::Gradient< C, InterFunc >
 ~Gradient ()
 destructor More...
 
void addPoint (float position, const C &color)
 add a point to this gradient. More...
 
Vector< GradientPoint< C > * >::Size getNumPoints () const
 get the number of points of this gradient. More...
 
GradientPoint< C > & operator[] (typename Vector< GradientPoint< C > * >::Size i)
 Operator [] to direct access points inside this gradient. More...
 
const GradientPoint< C > & operator[] (typename Vector< GradientPoint< C > * >::Size i) const
 Operator [] to direct access points inside this gradient. More...
 
template<size_t N, typename InterFunc2 = InterFunc>
void computeInterpolation (C(&buffer)[N], const InterFunc2 &functor=InterFunc(), float begin=0.0f, float end=1.0f) const
 Compute the interpolation of every color of this gradient in an 1D array. More...
 
template<typename InterFunc2 = InterFunc>
void computeInterpolation (C *buffer, size_t size, const InterFunc2 &functor=InterFunc(), float begin=0.0f, float end=1.0f) const
 Compute the interpolation of every color of this gradient in an 1D array. More...
 
void computeInterpolation (C *buffer, size_t size, float begin=0.0f, float end=1.0f) const
 Compute the interpolation of every color of this gradient in an 1D array. More...
 

Static Public Member Functions

static int computeIndex (const Math::Vec2< float > &p, int maxIndex, const Math::Vec2< float > &direction)
 Compute the index in the interpolated array. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Graphic::Gradient< C, InterFunc >
 Gradient (const InterFunc &functor=InterFunc())
 Create a new gradient. More...
 

Constructor & Destructor Documentation

template<typename C , typename InterFunc >
Graphic::GradientLinear< C, InterFunc >::GradientLinear ( float  angle,
const Math::Vec2< float > &  p = Math::Vec2<float>::null,
unsigned int  length = 0,
const InterFunc &  functor = InterFunc() 
)

Create a new Linear Gradient.

Parameters
angleAngle in degree point of this gradient.
lengthLength of this gradient (0 mean auto computed)
functorFunctor used to interpolate the colors overloaded with : template<typename C> inline C operator()(const C & color1, const C & color2, float x) const;

Member Function Documentation

template<typename C , typename InterFunc >
int Graphic::GradientLinear< C, InterFunc >::computeIndex ( const Math::Vec2< float > &  p,
int  maxIndex 
) const

Compute the index in the interpolated array.

Parameters
pPoint relative of this gradient.
maxIndexmaximal value of an interpolation table index.
Returns
Computed index.
template<typename C , typename InterFunc >
int Graphic::GradientLinear< C, InterFunc >::computeIndex ( const Math::Vec2< float > &  p,
int  maxIndex,
const Math::Vec2< float > &  direction 
)
static

Compute the index in the interpolated array.

Parameters
pPoint relative of this gradient.
maxIndexmaximal value of an interpolation table index.
directionUnitary vector representing the direction if this gradient.
Returns
Computed index.
template<typename C , typename InterFunc >
float Graphic::GradientLinear< C, InterFunc >::getAngle ( ) const

get the angle of this gradient

Returns
angle in degree
template<typename C , typename InterFunc >
float Graphic::GradientLinear< C, InterFunc >::getAngleRad ( ) const

get the angle of this gradient

Returns
angle in radians
template<typename C , typename InterFunc >
const Math::Vec2< float > & Graphic::GradientLinear< C, InterFunc >::getDirection ( ) const

get the unitary vector representing the direction of this gradient.

Returns
Unitary vector
template<typename C , typename InterFunc >
unsigned int Graphic::GradientLinear< C, InterFunc >::getLength ( ) const

get the length of this gradient

Returns
Length in pixels
template<typename C , typename InterFunc >
const Math::Vec2< float > & Graphic::GradientLinear< C, InterFunc >::getPoint ( ) const

get the point of this gradient

Returns
point (between 0 and 1)
template<typename C , typename InterFunc >
void Graphic::GradientLinear< C, InterFunc >::setAngle ( float  angle)

set the angle of this linear gradient

Parameters
angleAngle in Degree of this gradient (0 mean left to right) then it's anti clockwise
template<typename C , typename InterFunc >
void Graphic::GradientLinear< C, InterFunc >::setLength ( unsigned int  length)

brief set the length of this linear gradient param length Length in pixels (0 mean auto computed)

template<typename C , typename InterFunc >
void Graphic::GradientLinear< C, InterFunc >::setPoint ( const Math::Vec2< float > &  p)

set the starting point of this gradient

Parameters
pPoint (between 0 and 1)

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