50 class AnimatedBackend;
60 void update(std::vector<float> ×,
const float time_now) {
61 frame_above =
static_cast<int>(std::distance(
62 times.begin(), std::lower_bound(times.begin(), times.end(), time_now)));
64 if (frame_above == 0) {
69 const float delta_t = times[frame_above] - times[frame_above - 1];
70 w1 = (time_now - times[frame_above - 1]) / delta_t;
72 frame =
static_cast<float>(frame_above - 1) + w1;
136 void resize(
const bfloat2_t &parent_pixels);
140 void update_time_span(
float time);
143 void add_frame_time(
float time);
148 void update_frame_info(
float time);
165 Style &style() noexcept;
170 #ifdef TRASE_BACKEND_GL 173 virtual void dispatch(
BackendSVG &file,
float time) = 0;
177 template <
typename AnimatedBackend>
void draw(
AnimatedBackend &backend);
180 template <
typename Backend>
void draw(
Backend &backend,
float time);
185 #define TRASE_DISPATCH(backend_type) \ 186 void dispatch(backend_type &backend, float time) override { \ 187 draw(backend, time); \ 188 for (auto &i : m_children) { \ 189 i->dispatch(backend, time); \ 193 #define TRASE_ANIMATED_DISPATCH(backend_type) \ 194 void dispatch(backend_type &backend) override { \ 195 if (m_times.size() == 1) { \ 200 for (auto &i : m_children) { \ 201 i->dispatch(backend); \ 205 #define TRASE_DISPATCH_SVG \ 206 TRASE_DISPATCH(BackendSVG) \ 207 TRASE_ANIMATED_DISPATCH(BackendSVG) 209 #ifdef TRASE_BACKEND_GL 210 #define TRASE_DISPATCH_GL TRASE_DISPATCH(BackendGL) 212 #define TRASE_DISPATCH_GL 215 #define TRASE_DISPATCH_BACKENDS \ 219 #ifdef TRASE_BACKEND_GL 224 #endif // DRAWABLE_H_ std::vector< float > m_times
the animation frame times (see add_frame_time())
Definition: Drawable.hpp:117
a base class for all the backends that support drawing a single frame
Definition: Backend.hpp:50
Drawable * m_parent
parent of this object
Definition: Drawable.hpp:105
Style m_style
fully styling information for each drawable
Definition: Drawable.hpp:123
FrameInfo m_frame_info
stores information on the current draw time (see update_frame_info())
Definition: Drawable.hpp:120
float m_time_span
the animation time span (see update_time_span())
Definition: Drawable.hpp:114
Base class for drawable objects in a figure.
Definition: Drawable.hpp:99
const bfloat2_t & area() const
returns this objects drawable area as a ratio of the parents drawable area
Definition: Drawable.hpp:159
bfloat2_t m_pixels
the area of this object in raw pixels (updated by resize())
Definition: Drawable.hpp:111
Definition: BackendGL.hpp:55
bfloat2_t m_area
the area of this object as a ratio of its parent object
Definition: Drawable.hpp:108
bfloat2_t & area()
returns this objects drawable area as a ratio of the parents drawable area
Definition: Drawable.hpp:162
a base class for all the backends that support animation over time
Definition: Backend.hpp:62
const float & time_span() const
returns time span of the animation
Definition: Drawable.hpp:168
A helper struct for Drawable that holds frame-related information.
Definition: Drawable.hpp:53
Definition: BackendSVG.hpp:73
std::vector< std::shared_ptr< Drawable > > m_children
a list of Drawables that are children of this object
Definition: Drawable.hpp:102
Definition: Backend.cpp:39
const bfloat2_t & pixels() const
returns this objects drawable area in raw pixels
Definition: Drawable.hpp:156