trase
trase::Figure Class Reference

The primary Drawable for each figure. More...

#include <Figure.hpp>

Inheritance diagram for trase::Figure:
Collaboration diagram for trase::Figure:

Public Member Functions

 Figure (const std::array< float, 2 > &pixels)
 create a new figure with the given number of pixels More...
 
TRASE_DISPATCH_BACKENDS std::shared_ptr< Axisaxis ()
 Create a new axis at position (0,0) and return a shared pointer to it If the axis already exists returns a pointer to the existing axis. More...
 
std::shared_ptr< Axisaxis (int i, int j)
 Create a new axis at position (i, j) and return a shared pointer to it If the axis already exists returns a pointer to the existing axis. More...
 
template<typename Backend >
void show (Backend &backend)
 Draw the Figure using the Backend provided. More...
 
template<typename AnimatedBackend >
void draw (AnimatedBackend &backend)
 Draw the Figure using the AnimatedBackend provided. More...
 
template<typename Backend >
void draw (Backend &backend, float time)
 Draw the Figure at a given time using the Backend provided. More...
 
- Public Member Functions inherited from trase::Drawable
 Drawable (Drawable *parent, const bfloat2_t &area_of_parent)
 constructs a Drawable under parent in the tree structure, and assigns it an drawable area given by area_of_parent More...
 
void resize (const bfloat2_t &parent_pixels)
 resize the drawable area (in raw pixels) using the parents area (in raw pixels)
 
void update_time_span (float time)
 if time is outside the current animation time span of this object then this time span is increased to include it
 
void add_frame_time (float time)
 adds a keyframe time to the animation
 
void update_frame_info (float time)
 fills out m_frame_info using a given time More...
 
const FrameInfoget_frame_info () const
 returns the current FrameInfo More...
 
const bfloat2_tpixels () const
 returns this objects drawable area in raw pixels
 
const bfloat2_tarea () const
 returns this objects drawable area as a ratio of the parents drawable area
 
bfloat2_tarea ()
 returns this objects drawable area as a ratio of the parents drawable area
 
Stylestyle () noexcept
 returns modifiable current style
 
const float & time_span () const
 returns time span of the animation
 
virtual void dispatch (BackendSVG &file, float time)=0
 
virtual void dispatch (BackendSVG &file)=0
 
template<typename AnimatedBackend >
void draw (AnimatedBackend &backend)
 draw this object using the given AnimatedBackend
 
template<typename Backend >
void draw (Backend &backend, float time)
 draw this object using the given Backend
 

Additional Inherited Members

- Protected Attributes inherited from trase::Drawable
std::vector< std::shared_ptr< Drawable > > m_children
 a list of Drawables that are children of this object
 
Drawablem_parent
 parent of this object
 
bfloat2_t m_area
 the area of this object as a ratio of its parent object
 
bfloat2_t m_pixels
 the area of this object in raw pixels (updated by resize())
 
float m_time_span
 the animation time span (see update_time_span())
 
std::vector< float > m_times
 the animation frame times (see add_frame_time())
 
FrameInfo m_frame_info
 stores information on the current draw time (see update_frame_info())
 
Style m_style
 fully styling information for each drawable
 

Detailed Description

The primary Drawable for each figure.

Each Figure points to one or more Axis objects that are drawn within the Figure.

Constructor & Destructor Documentation

◆ Figure()

trase::Figure::Figure ( const std::array< float, 2 > &  pixels)
explicit

create a new figure with the given number of pixels

Parameters
pixelsthe number of pixels along the {width, height} of the figure

Member Function Documentation

◆ axis() [1/2]

std::shared_ptr< Axis > trase::Figure::axis ( )

Create a new axis at position (0,0) and return a shared pointer to it If the axis already exists returns a pointer to the existing axis.

Returns
a shared pointer to the new axis

◆ axis() [2/2]

std::shared_ptr< Axis > trase::Figure::axis ( int  i,
int  j 
)

Create a new axis at position (i, j) and return a shared pointer to it If the axis already exists returns a pointer to the existing axis.

Returns
a shared pointer to the new axis

◆ draw() [1/2]

template<typename AnimatedBackend >
void trase::Figure::draw ( AnimatedBackend backend)

Draw the Figure using the AnimatedBackend provided.

Parameters
backendthe AnimatedBackend used to draw the figure.

◆ draw() [2/2]

template<typename Backend >
void trase::Figure::draw ( Backend backend,
float  time 
)

Draw the Figure at a given time using the Backend provided.

Parameters
backendthe Backend used to draw the figure.
timethe Figure is drawn at this time

◆ show()

template<typename Backend >
void trase::Figure::show ( Backend backend)

Draw the Figure using the Backend provided.

This function takes control of the render loop and animates the Figure until the window is closed.

TODO: issue #86 - only works for the BackendGL backend

Parameters
backendthe Backend used to draw the figure.

The documentation for this class was generated from the following files: