LibreOffice Module basegfx (master) 1
Public Types | Public Member Functions | Private Attributes | List of all members
basegfx::utils::KeyStopLerp Class Reference

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
 

Detailed Description

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.

Member Typedef Documentation

◆ ResultType

typedef std::pair<std::ptrdiff_t,double> basegfx::utils::KeyStopLerp::ResultType

Definition at line 45 of file keystoplerp.hxx.

Constructor & Destructor Documentation

◆ KeyStopLerp() [1/2]

basegfx::utils::KeyStopLerp::KeyStopLerp ( std::vector< double > &&  rKeyStops)
explicit

Create lerper with given vector of stops.

Parameters
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().

◆ KeyStopLerp() [2/2]

basegfx::utils::KeyStopLerp::KeyStopLerp ( const css::uno::Sequence< double > &  rKeyStops)
explicit

Create lerper with given sequence of stops.

Parameters
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.

Member Function Documentation

◆ lerp()

KeyStopLerp::ResultType basegfx::utils::KeyStopLerp::lerp ( double  fAlpha) const

Find two nearest bucket index & interpolate.

Parameters
fAlphaFind 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.

Member Data Documentation

◆ maKeyStops

std::vector<double> basegfx::utils::KeyStopLerp::maKeyStops
private

Definition at line 80 of file keystoplerp.hxx.

Referenced by KeyStopLerp(), and lerp().

◆ mnLastIndex

std::ptrdiff_t basegfx::utils::KeyStopLerp::mnLastIndex
mutableprivate

Definition at line 81 of file keystoplerp.hxx.

Referenced by lerp().


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