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:
Zed A. Shaw 2026-02-04 00:59:26 -05:00
parent 383f839fdf
commit 07b2102f59
6 changed files with 69 additions and 18 deletions

View file

@ -33,7 +33,6 @@ namespace animate2 {
playing = true;
sequence.timer.start();
sequence.frame_count = sequence.frames.size();
$frame_rects = calc_frames();
}
void Animate2::stop() {
@ -149,9 +148,9 @@ namespace animate2 {
void Transform::lerp(Sequence& seq, sf::Vector2f& pos_out, sf::Vector2f& scale_out) {
// float dt = 1 - std::powf(ease_rate, seq.subframe + 0.0001);
float tick = easing(seq.subframe);
float tick = easing_func(seq.subframe);
motion(*this, pos_out, scale_out, tick);
motion_func(*this, pos_out, scale_out, tick);
// fmt::println("sub: {}, tick: {}, tr: {},{}; pos: {},{}; scale: {},{}",
// seq.subframe, tick, min_y, max_y, pos_out.x, pos_out.y,
@ -166,6 +165,11 @@ namespace animate2 {
Animate2 anim;
animate2::from_json(data[anim_name], anim);
// BUG: json doesn't like may "fancy" no-constructor bullshit
anim.$frame_rects = anim.calc_frames();
anim.transform.easing_func = ease2::get_easing(anim.transform.easing);
anim.transform.motion_func = ease2::get_motion(anim.transform.motion);
return anim;
}
}