LibreOffice Module basegfx (master) 1
|
Lerp in a vector of key stops. More...
#include <keystoplerp.hxx>
Public Types | |
typedef std::pair< std::ptrdiff_t, double > | ResultType |
Public Member Functions | |
KeyStopLerp (std::vector< double > &&rKeyStops) | |
Create lerper with given vector of stops. More... | |
KeyStopLerp (const css::uno::Sequence< double > &rKeyStops) | |
Create lerper with given sequence of stops. More... | |
ResultType | lerp (double fAlpha) const |
Find two nearest bucket index & interpolate. More... | |
Private Attributes | |
std::vector< double > | maKeyStops |
std::ptrdiff_t | mnLastIndex |
Lerp in a vector of key stops.
This class holds a key stop vector and provides the functionality to lerp inside it. Useful e.g. for multi-stop gradients, or the SMIL key time activity.
For those, given a global [0,1] lerp alpha, one need to find the suitable bucket index from key stop vector, and then calculate the relative alpha between the two buckets found.
Definition at line 42 of file keystoplerp.hxx.
typedef std::pair<std::ptrdiff_t,double> basegfx::utils::KeyStopLerp::ResultType |
Definition at line 45 of file keystoplerp.hxx.
|
explicit |
Create lerper with given vector of stops.
rKeyStops |
Vector of stops, must contain at least two elements (though preferably more, otherwise you probably don't need key stop lerping in the first place). All elements must be of monotonically increasing value.
Definition at line 45 of file keystoplerp.cxx.
References maKeyStops, and validateInput().
|
explicit |
Create lerper with given sequence of stops.
rKeyStops |
Sequence of stops, must contain at least two elements (though preferably more, otherwise you probably don't need key stop lerping in the first place). All elements must be of monotonically increasing value.
KeyStopLerp::ResultType basegfx::utils::KeyStopLerp::lerp | ( | double | fAlpha | ) | const |
Find two nearest bucket index & interpolate.
fAlpha | Find bucket index i, with keyStops[i] < fAlpha <= keyStops[i+1]. Return new alpha value in [0,1), proportional to fAlpha's position between keyStops[i] and keyStops[i+1] |
Definition at line 59 of file keystoplerp.cxx.
References maKeyStops, and mnLastIndex.
|
private |
Definition at line 80 of file keystoplerp.hxx.
Referenced by KeyStopLerp(), and lerp().
|
mutableprivate |
Definition at line 81 of file keystoplerp.hxx.
Referenced by lerp().