The gorious Lord Keith the Rat King can now have easing and motion functions that are defined in json and hot-reloaded.
This commit is contained in:
parent
383f839fdf
commit
07b2102f59
6 changed files with 69 additions and 18 deletions
37
ease2.cpp
37
ease2.cpp
|
|
@ -2,6 +2,8 @@
|
|||
#include "rand.hpp"
|
||||
#include "animate2.hpp"
|
||||
#include <fmt/core.h>
|
||||
#include <unordered_map>
|
||||
#include "dbc.hpp"
|
||||
|
||||
namespace ease2 {
|
||||
using namespace animate2;
|
||||
|
|
@ -96,4 +98,39 @@ namespace ease2 {
|
|||
scale_out.x = std::lerp(scale_out.x * tr.min_x, scale_out.x * tr.max_x, tick);
|
||||
scale_out.y = std::lerp(scale_out.y * tr.min_y, scale_out.y * tr.max_y, tick);
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, EaseFunc> map_of_easings{
|
||||
{"sine", sine},
|
||||
{"out_circle", out_circle},
|
||||
{"out_bounce", out_bounce},
|
||||
{"in_out_back", in_out_back},
|
||||
{"random", random},
|
||||
{"normal_dist", normal_dist},
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, MotionFunc> map_of_motions{
|
||||
{"move_bounce", move_bounce},
|
||||
{"move_rush", move_rush},
|
||||
{"scale_squeeze", scale_squeeze},
|
||||
{"scale_squash", scale_squash},
|
||||
{"scale_stretch", scale_stretch},
|
||||
{"scale_grow", scale_grow},
|
||||
{"move_slide", move_slide},
|
||||
{"move_none", move_none},
|
||||
{"scale_only", scale_only},
|
||||
{"move_shake", move_shake},
|
||||
};
|
||||
|
||||
EaseFunc get_easing(const std::string& name) {
|
||||
dbc::check(map_of_easings.contains(name),
|
||||
fmt::format("easing name {} does not exist", name));
|
||||
return map_of_easings.at(name);
|
||||
}
|
||||
|
||||
MotionFunc get_motion(const std::string& name) {
|
||||
dbc::check(map_of_motions.contains(name),
|
||||
fmt::format("motion name {} does not exist", name));
|
||||
return map_of_motions.at(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue