An object that, when active, repeatedly calls a function as fast as possible, to a maximum of 60 frames per second.
More...
#include <Animate.h>
|
using | anim_fun_t = std::function< void(const Animate &)> |
| The full version of the animate function takes a const reference to the animate object. More...
|
|
An object that, when active, repeatedly calls a function as fast as possible, to a maximum of 60 frames per second.
Parameters to the animation function can be:
- double (representing time since the last frame)
- a const reference to the animation object itself
- nothing
Control methods: void Start() void Stop() void Step() void ToggleActive()
Access methods: bool GetActive() const bool GetDoStep() const double GetStartTime() const double GetPrevTime() const double GetCurTime() const double GetStepTime() const double GetRunTime() const int GetFrameCount() const
Config methods: void SetCallback(const std::function<void(const Animate &)> & fun) void SetCallback(const std::function<void(double)> & fun) void SetCallback(const std::function<void()> & fun)
The full version of the animate function takes a const reference to the animate object.
emp::web::Animate::Animate |
( |
| ) |
|
|
inline |
Setup an Animate object to call an anim_fun as fast as possible, at most 60 times a second. Call virtual function DoFrame() if no other functon is provided (which can be overridden if you derive a new class from Animate)
template<typename... W_TYPES>
emp::web::Animate::Animate |
( |
const anim_fun_t & |
fun, |
|
|
W_TYPES &... |
targets |
|
) |
| |
|
inline |
Construct an Animate object with the function to run each animation step and zero or more UI elements that should be updated after each frame.
template<typename... W_TYPES>
emp::web::Animate::Animate |
( |
const std::function< void(double)> & |
fun, |
|
|
W_TYPES &... |
targets |
|
) |
| |
|
inline |
template<typename... W_TYPES>
emp::web::Animate::Animate |
( |
const std::function< void()> & |
fun, |
|
|
W_TYPES &... |
targets |
|
) |
| |
|
inline |
virtual emp::web::Animate::~Animate |
( |
| ) |
|
|
inlinevirtual |
emp::web::Animate::Animate |
( |
const Animate & |
| ) |
|
|
delete |
Do not copy animations directly.
void emp::web::Animate::AdvanceFrame |
( |
| ) |
|
|
inlineprotected |
virtual void emp::web::Animate::DoFrame |
( |
| ) |
|
|
inlineprotectedvirtual |
DoFrame() is called by default if no animation function is provided. As such, an animation can be built by deriving a class from Animate and overriding this function.
bool emp::web::Animate::GetActive |
( |
| ) |
const |
|
inline |
Determine if this animation is currently running.
double emp::web::Animate::GetCurTime |
( |
| ) |
const |
|
inline |
Get the current time of the animation.
bool emp::web::Animate::GetDoStep |
( |
| ) |
const |
|
inline |
Determine if this animation is currently in the process of running a single step.
int emp::web::Animate::GetFrameCount |
( |
| ) |
const |
|
inline |
Determine how many total frames have existed thus far in this animation.
double emp::web::Animate::GetPrevTime |
( |
| ) |
const |
|
inline |
Determine the time point when this animation last updated a frame.
double emp::web::Animate::GetRunTime |
( |
| ) |
const |
|
inline |
Determine the total amount of time that this animation has run.
double emp::web::Animate::GetStartTime |
( |
| ) |
const |
|
inline |
Return the time point that this animation started MOST RECENTLY.
Button emp::web::Animate::GetStepButton |
( |
const std::string & |
but_name, |
|
|
const std::string & |
label = "Step" |
|
) |
| |
|
inline |
Get a step button that will advance this animation one frame.
- Parameters
-
but_name | The HTML identifier used for this button. |
label | The name shown on the button. |
double emp::web::Animate::GetStepTime |
( |
| ) |
const |
|
inline |
Determine how long the last step between frames took.
Button emp::web::Animate::GetToggleButton |
( |
const std::string & |
but_name, |
|
|
const std::string & |
start_label = "Start" , |
|
|
const std::string & |
stop_label = "Stop" |
|
) |
| |
|
inline |
Get a toggle button that will start/stop this animation.
- Parameters
-
but_name | The HTML identifier used for this button. |
start_label | The name on the button when it will start the animation (default="Start") |
stop_label | The name on the button when it will halt the animation (default="Stop") |
void emp::web::Animate::LoadTargets |
( |
| ) |
|
|
inlineprotected |
template<typename... T>
void emp::web::Animate::LoadTargets |
( |
const web::Widget & |
target1, |
|
|
const T &... |
other_targets |
|
) |
| |
|
inlineprotected |
void emp::web::Animate::SetCallback |
( |
const anim_fun_t & |
fun | ) |
|
|
inline |
Set a new function for this animation to call when running that takes a const reference to the Animation object as an argument.
void emp::web::Animate::SetCallback |
( |
const std::function< void(double)> & |
fun | ) |
|
|
inline |
Set a new function for this animation to call when running that takes the amount of time since the last frame (a double) as an argument.
void emp::web::Animate::SetCallback |
( |
const std::function< void()> & |
fun | ) |
|
|
inline |
Set a new function for this animation to call when running that takes no arguments.
void emp::web::Animate::Start |
( |
| ) |
|
|
inline |
Start this animation running.
void emp::web::Animate::Step |
( |
| ) |
|
|
inline |
Take a single step in this animation.
void emp::web::Animate::Stop |
( |
| ) |
|
|
inline |
Halt this animation for now.
void emp::web::Animate::ToggleActive |
( |
| ) |
|
|
inline |
Toggle whether this animation is running or paused.
bool emp::web::Animate::active |
|
protected |
Is this animation currently running?
Function to repeatedly run for animation.
size_t emp::web::Animate::callback_id |
|
protected |
double emp::web::Animate::cur_time |
|
protected |
What time did the current frame start?
bool emp::web::Animate::do_step |
|
protected |
Should this animation take just a single step?
int emp::web::Animate::frame_count |
|
protected |
How many animation frames have gone by?
double emp::web::Animate::prev_time |
|
protected |
What was the time point of the previous frame?
double emp::web::Animate::run_time |
|
protected |
How much run time has accumulated?
double emp::web::Animate::start_time |
|
protected |
At what time did this animation most recently start?
Button emp::web::Animate::step_but |
|
protected |
A button to advance this animation one step.
What widgets should be refreshed after each frame?
Button emp::web::Animate::toggle_but |
|
protected |
A button to start/stop this animation.
The documentation for this class was generated from the following file: