nCine::ColorAffector class

Affector that animates the color of a particle.

Linearly interpolates the particle color between consecutive ColorStep entries ordered by age.

Base classes

class ParticleAffector
Base class for all particle affectors.

Public types

struct ColorStep
A color keyed to a normalized particle age.

Constructors, destructors, conversion operators

ColorAffector()
ColorAffector(ColorAffector&&) defaulted
Default move constructor.
ColorAffector(const ColorAffector& other) protected defaulted
Protected default copy constructor used to clone objects.

Public functions

auto operator=(ColorAffector&&) -> ColorAffector& defaulted
Default move assignment operator.
auto clone() const -> ColorAffector
Returns a copy of this object.
void affect(Particle* particle, float normalizedAge) override
Affects a property of the specified particle using a precomputed normalized age.
void addColorStep(float age, const Colorf& color)
Appends a color step at the specified age.
auto steps() -> SmallVectorImpl<ColorStep>&
Returns the array of color steps.
auto steps() const -> const SmallVectorImpl<ColorStep>&
Returns the array of color steps (read-only).

Function documentation

void nCine::ColorAffector::affect(Particle* particle, float normalizedAge) override

Affects a property of the specified particle using a precomputed normalized age.

Parameters
particle Particle to mutate
normalizedAge Particle age mapped to the [0, 1] range, where 0 is birth and 1 is death

void nCine::ColorAffector::addColorStep(float age, const Colorf& color)

Appends a color step at the specified age.

Steps must be added in ascending age order; an out-of-order step is rejected with a warning.