Smolgui
Immediate gui library based on SFML
Loading...
Searching...
No Matches
Interpolation.h
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4#include <string>
5#include <cstdint>
6#include <type_traits>
7
8// forward declaration
9namespace sf {
10 class Color;
11 template <typename T> class Vector2;
12 template <typename T> class Vector3;
13}
14
15namespace sgui
16{
20template <typename Type>
21constexpr sf::Vector2<Type> round (const sf::Vector2<Type>& value);
22
26template <typename Type>
27constexpr sf::Vector2<Type> round (const sf::Vector3<Type>& value);
28
33template <typename Type>
34constexpr Type lerp (
35 const Type& min,
36 const Type& max,
37 const float value);
38
42sf::Color lerp (
43 const sf::Color& a,
44 const sf::Color& b,
45 const float value);
46
50template <typename Type>
51constexpr Type clamp (
52 const Type min,
53 const Type max,
54 const Type value);
55
60template <typename Type>
61constexpr Type clampedLerp (
62 const Type& min,
63 const Type& max,
64 const float value);
65
69template <typename Type>
70constexpr float inverseLerp (
71 const Type& min,
72 const Type& max,
73 const Type& value);
74
79template <typename InputType,
80 typename OutputType>
81constexpr OutputType remap (
82 const InputType& minInput,
83 const InputType& maxInput,
84 const OutputType& minOutput,
85 const OutputType& maxOutput,
86 const InputType& value);
87
88} // namespace sgui
89
Definition Interpolation.h:11
Definition Interpolation.h:12
Definition Interpolation.h:9
Definition Interpolation.h:16
constexpr Type clampedLerp(const Type &min, const Type &max, const float value)
Clamped linear interpolation, it always return a value in [min, max] regardless of if value is in [0,...
constexpr OutputType remap(const InputType &minInput, const InputType &maxInput, const OutputType &minOutput, const OutputType &maxOutput, const InputType &value)
Remap a value from [minInput, maxInput] range to [minOutput, maxOutput], depending on where value is ...
constexpr sf::Vector2< Type > round(const sf::Vector2< Type > &value)
Round sf::Vector2 components.
constexpr Type lerp(const Type &min, const Type &max, const float value)
Linear interpolation between min and max if value belong to [0, 1], with extrapolation otherwise (see...
constexpr Type clamp(const Type min, const Type max, const Type value)
Clamp value between min and max.
constexpr float inverseLerp(const Type &min, const Type &max, const Type &value)
Inverse linear interpolation. Return in [0, 1] range if value is in [min, max].