nCine::SizeAffector class

Affector that animates the scale of a particle.

Linearly interpolates the scale between consecutive SizeStep entries; the interpolated value is multiplied by a constant base scale applied to every particle.

Base classes

class ParticleAffector
Base class for all particle affectors.

Public types

struct SizeStep
A scale factor keyed to a normalized particle age.

Constructors, destructors, conversion operators

SizeAffector()
Constructs a size affector with a unit base scale factor.
SizeAffector(float baseScale) explicit
Constructs a size affector with a uniform base scale factor.
SizeAffector(float baseScaleX, float baseScaleY)
Constructs a size affector with a horizontal and a vertical base scale factor.
SizeAffector(Vector2f baseScale) explicit
Constructs a size affector with a vector base scale factor.
SizeAffector(SizeAffector&&) defaulted
Default move constructor.
SizeAffector(const SizeAffector& other) protected defaulted
Protected default copy constructor used to clone objects.

Public functions

auto operator=(SizeAffector&&) -> SizeAffector& defaulted
Default move assignment operator.
auto clone() const -> SizeAffector
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 addSizeStep(float age, float scale)
Appends a uniform scale step at the specified age.
void addSizeStep(float age, float scaleX, float scaleY)
Appends a non-uniform scale step at the specified age.
void addSizeStep(float age, Vector2f scale)
Appends a vector scale step at the specified age.
auto steps() -> SmallVectorImpl<SizeStep>&
Returns the array of size steps.
auto steps() const -> const SmallVectorImpl<SizeStep>&
Returns the array of size steps (read-only).
auto baseScaleX() const -> float
Returns the horizontal base scale factor.
void setBaseScaleX(float baseScaleX)
Sets the horizontal base scale factor.
auto baseScaleY() const -> float
Returns the vertical base scale factor.
void setBaseScaleY(float baseScaleY)
Sets the vertical base scale factor.
auto baseScale() const -> Vector2f
Returns the base scale factor.
void setBaseScale(float baseScale)
Sets a uniform base scale factor.
void setBaseScale(Vector2f baseScale)
Sets a vector base scale factor.

Function documentation

void nCine::SizeAffector::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::SizeAffector::addSizeStep(float age, float scaleX, float scaleY)

Appends a non-uniform scale step at the specified age.

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