GradientSampler< T_ModeNone, T_ModeLinearKnot, T_ModeSmoothKnot, T_ModeBlend, T_ModeCubicKnot, T_ModeCubicBias > Class Template Reference

#include <gradientmath.h>

Inheritance diagram for GradientSampler< T_ModeNone, T_ModeLinearKnot, T_ModeSmoothKnot, T_ModeBlend, T_ModeCubicKnot, T_ModeCubicBias >:

Detailed Description

template<typename T_ModeNone, typename T_ModeLinearKnot, typename T_ModeSmoothKnot, typename T_ModeBlend, typename T_ModeCubicKnot, typename T_ModeCubicBias>
class maxon::GradientSampler< T_ModeNone, T_ModeLinearKnot, T_ModeSmoothKnot, T_ModeBlend, T_ModeCubicKnot, T_ModeCubicBias >

This class adds a little convenience to setup a gradient for a set of interpolation modes given as MAXON_ATTRIBUTE. For example, a gradient can be configured as such:

// We setup the knot sequence.
maxon::Color knotValues[2] = { maxon::Color(0), maxon::Color(1) };
sortedKnots.InsertKnot(0.0) iferr_return;
sortedKnots.InsertKnot(1.0) iferr_return;
sortedKnots.Sort() iferr_return;
// We setup the gradient sampler instance.
using InterpolationNone = decltype(maxonexample::DATATYPE::PORTBUNDLE::GRADIENT::INTERPOLATION_ENUM_NONE);
using InterpolationLinearKnot = decltype(maxonexample::DATATYPE::PORTBUNDLE::GRADIENT::INTERPOLATION_ENUM_LINEARKNOT);
using InterpolationSmoothKnot = decltype(maxonexample::DATATYPE::PORTBUNDLE::GRADIENT::INTERPOLATION_ENUM_SMOOTHKNOT);
using InterpolationBlend = decltype(maxonexample::DATATYPE::PORTBUNDLE::GRADIENT::INTERPOLATION_ENUM_BLEND);
using InterpolationCubicKnot = decltype(maxonexample::DATATYPE::PORTBUNDLE::GRADIENT::INTERPOLATION_ENUM_CUBICKNOT);
using InterpolationCubicBias = decltype(maxonexample::DATATYPE::PORTBUNDLE::GRADIENT::INTERPOLATION_ENUM_CUBICBIAS);
auto GetKnotValue = [&knotValues](Int index)
{
return knotValues[index];
};
auto GetKnotInterpolationMode = [](Int index)
{
return InterpolationLinearKnot::GetId().GetHashCode();
};
auto GetKnotBias = [](Int index)
{
return Float(0.5);
};
// We sample the gradient in the middle.
const maxon::Color gray = gradientSampler.Sample<maxon::Color>(0.5, sortedKnots, GetKnotValue, GetKnotInterpolationMode, GetKnotBias) iferr_return;
Definition: gradientmath.h:526
Result< ValueType > Sample(typename SortedKnotsType::FloatType absolutePosition, const SortedKnotsType &sortedKnots, const GetKnotValueFunc &getKnotValue, const GetKnotInterpolationModeFunc &getKnotInterpolationMode, const GetKnotBiasFunc &getKnotBias) const
Definition: gradientmath.h:399
Definition: gradientmath.h:53
Result< void > Sort()
Definition: gradientmath.h:173
Result< void > InsertKnot(FloatType position)
Definition: gradientmath.h:84
Py_ssize_t * index
Definition: abstract.h:374
maxon::Int Int
Definition: ge_sys_math.h:64
Float64 Float
Definition: apibase.h:197
Col3< Float, 1 > Color
Definition: vector.h:84
#define iferr_return
Definition: resultbase.h:1519
constexpr HashInt GetHashCode() const
Definition: col.h:274

Additional Inherited Members

- Public Member Functions inherited from IndexedGradientSampler< T_ModeNone::GetId().GetHashCode(), T_ModeLinearKnot::GetId().GetHashCode(), T_ModeSmoothKnot::GetId().GetHashCode(), T_ModeBlend::GetId().GetHashCode(), T_ModeCubicKnot::GetId().GetHashCode(), T_ModeCubicBias::GetId().GetHashCode()>
Result< ValueType > Sample (typename SortedKnotsType::FloatType absolutePosition, const SortedKnotsType &sortedKnots, const GetKnotValueFunc &getKnotValue, const GetKnotInterpolationModeFunc &getKnotInterpolationMode, const GetKnotBiasFunc &getKnotBias) const