trase
trase::BackendSVG Class Reference
Inheritance diagram for trase::BackendSVG:
Collaboration diagram for trase::BackendSVG:

Public Member Functions

 BackendSVG (std::ostream &out)
 create a new backend which will write out an animated SVG to the output stream out
 
void init (const vfloat2_t &pixels, const char *name, float time_span=0.f) noexcept
 Initialise the backend. More...
 
void finalise () noexcept
 Finalise the backend. More...
 
bool is_interactive ()
 returns false
 
bool should_close ()
 returns true
 
vfloat2_t begin_frame ()
 not used (only used for interactive backends)
 
void end_frame ()
 not used (only used for interactive backends)
 
vfloat2_t get_mouse_pos ()
 this backend is not interactive so return value is undefined
 
float get_time ()
 not used (only used for interactive backends)
 
bool mouse_dragging ()
 not used (only used for interactive backends)
 
vfloat2_t mouse_drag_delta ()
 not used (only used for interactive backends)
 
void mouse_drag_reset_delta ()
 not used (only used for interactive backends)
 
void scissor (const bfloat2_t &x)
 all subsequent drawing calls will be cut to within this box
 
void reset_scissor ()
 resets any previous calls to scissor()
 
void rotate (const float angle)
 rotates the drawing transform by an angle given by angle
 
void reset_transform ()
 resets the drawing transform to identity More...
 
void translate (const vfloat2_t &v)
 translates the drawing transform by an amount given by v
 
void begin_path ()
 begin a drawing path More...
 
void move_to (const vfloat2_t &x)
 move the "pen" to the point x without drawing a line More...
 
void line_to (const vfloat2_t &x)
 draw a line to the point x More...
 
void close_path ()
 draw a line to the first point of the path More...
 
void stroke ()
 finalise a drawing path with a drawn line along the path More...
 
void fill ()
 finalise a drawing path with a drawn line and a filled enclosed domain More...
 
void begin_animated_path ()
 begin an animated path More...
 
void add_animated_path (const float time)
 finalise the current path and add a new path at time time More...
 
void end_animated_path (const float time)
 finalise the current animated path More...
 
void rounded_rect (const bfloat2_t &x, float r) noexcept
 draw a rectangle with rounded corners More...
 
void rect (const bfloat2_t &x, float r=0.f) noexcept
 draw a rectangle, optionally with rounded corners More...
 
void add_animated_rect (const bfloat2_t &x, float time)
 start/continue an animated rectangle. More...
 
void add_animated_stroke (const RGBA &color)
 Used in conjunction with add_animated_path, add_animated_rect, add_animated_circle, to provide animated stroke color/opacity. More...
 
void add_animated_fill (const RGBA &color)
 Used in conjunction with add_animated_path, add_animated_rect, add_animated_circle, to provide animated fill color/opacity. More...
 
void end_animated_rect ()
 end an animated rectangle
 
void circle (const vfloat2_t &centre, float r) noexcept
 draw a circle More...
 
void add_animated_circle (const vfloat2_t &centre, float radius, float time)
 start/continue an animated circle subsequent calls to this method will add extra keyframe to the animation. More...
 
void end_animated_circle ()
 end an animated circle
 
void circle_with_text (const vfloat2_t &centre, float radius, const char *string)
 draw a circle with with a string label More...
 
void arc (const vfloat2_t &centre, const float radius, const float angle0, const float angle1)
 draw an arc More...
 
void stroke_color (const RGBA &color)
 set the current stroke color
 
void stroke_color (const RGBA &color, const RGBA &color_mouseover)
 set the current stroke color, with a different color to display on mouseover
 
void tooltip (const vfloat2_t &x, const char *string)
 Set a tooltip. More...
 
void clear_tooltip ()
 Unset the tooltip. More...
 
void stroke_width (const float lw)
 sets the current stroke width
 
void fill_color (const RGBA &color)
 set the current fill color
 
void fill_color (const RGBA &color, const RGBA &color_mouseover)
 set the current fill color, with a different color on mouseover
 
void font_size (float size)
 set the current font height
 
void font_face (const char *face)
 sets the current font
 
void import_web_font (const std::string &url)
 sets a web font More...
 
void font_blur (const float blur)
 set the amount of font blur on text
 
void text_align (const unsigned int align)
 sets the current text alignment
 
void text (const vfloat2_t &x, const char *string, const char *end)
 draws text to a given position More...
 
- Public Member Functions inherited from trase::AnimatedBackend
virtual void accept (Drawable &drawable)=0
 
- Public Member Functions inherited from trase::Backend
virtual void accept (Drawable &drawable, float time)=0
 

Static Public Member Functions

static void set_mouse_down (const vfloat2_t &mouse_pos)
 not used (only used for interactive backends)
 
static void set_mouse_up ()
 not used (only used for interactive backends)
 

Member Function Documentation

◆ add_animated_circle()

void BackendSVG::add_animated_circle ( const vfloat2_t centre,
float  radius,
float  time 
)

start/continue an animated circle subsequent calls to this method will add extra keyframe to the animation.

Parameters
centrethe centre of the circle
radiusthe radius of the circle
colorthe color of the circle
timethe time of the keyframe

◆ add_animated_fill()

void BackendSVG::add_animated_fill ( const RGBA color)

Used in conjunction with add_animated_path, add_animated_rect, add_animated_circle, to provide animated fill color/opacity.

Must by called once for each of the above methods

Parameters
colorthe fill color of the current keyframe

◆ add_animated_path()

void BackendSVG::add_animated_path ( const float  time)

finalise the current path and add a new path at time time

Note that filled paths are not currently supported by the animated path

See also
begin_animated_path()

◆ add_animated_rect()

void BackendSVG::add_animated_rect ( const bfloat2_t x,
float  time 
)

start/continue an animated rectangle.

subsequent calls to this method will add extra keyframe to the animation.

Parameters
xthe bounding box of the rectangle
strokethe stroke color of the circle
fillthe fill color of the circle
timethe time of the keyframe

◆ add_animated_stroke()

void BackendSVG::add_animated_stroke ( const RGBA color)

Used in conjunction with add_animated_path, add_animated_rect, add_animated_circle, to provide animated stroke color/opacity.

Must by called once for each of the above methods

Parameters
colorthe stroke color of the current keyframe

◆ arc()

void BackendSVG::arc ( const vfloat2_t centre,
const float  radius,
const float  angle0,
const float  angle1 
)

draw an arc

Parameters
centrethe centre of the arc radius the radius of the arc
angle0the start angle of the arc
angle1the end angle of the arc

◆ begin_animated_path()

void trase::BackendSVG::begin_animated_path ( )

begin an animated path

must be called before move_to(), line_to(), add_animated_path(), or end_animated_path()

◆ begin_path()

void BackendSVG::begin_path ( )

begin a drawing path

must be called before move_to(), line_to(), or close_path()

◆ circle()

void BackendSVG::circle ( const vfloat2_t centre,
float  r 
)
noexcept

draw a circle

Parameters
centrecoordinates of the centre of the circle
rthe radius of the circle

◆ circle_with_text()

void BackendSVG::circle_with_text ( const vfloat2_t centre,
float  radius,
const char *  string 
)

draw a circle with with a string label

Parameters
centrethe centre of the circle
radiusthe radius of the circle
stringthe string text

◆ clear_tooltip()

void BackendSVG::clear_tooltip ( )

Unset the tooltip.

See also
tooltip()

◆ close_path()

void BackendSVG::close_path ( )

draw a line to the first point of the path

See also
begin_path()

◆ end_animated_path()

void BackendSVG::end_animated_path ( const float  time)

finalise the current animated path

Note that filled paths are not currently supported by the animated path

See also
begin_animated_path()

◆ fill()

void BackendSVG::fill ( )

finalise a drawing path with a drawn line and a filled enclosed domain

See also
begin_path()

◆ finalise()

void trase::BackendSVG::finalise ( )
noexcept

Finalise the backend.

This function must be called after all drawing is complete

◆ import_web_font()

void BackendSVG::import_web_font ( const std::string &  url)

sets a web font

must be called before init()

◆ init()

void trase::BackendSVG::init ( const vfloat2_t pixels,
const char *  name,
float  time_span = 0.f 
)
noexcept

Initialise the backend.

This function must be called before any other drawing calls

Parameters
pixelsthe image resolution in pixels
namethe name of the image
time_spanthe total time span of the animated svg

◆ line_to()

void BackendSVG::line_to ( const vfloat2_t x)

draw a line to the point x

See also
begin_path()

◆ move_to()

void BackendSVG::move_to ( const vfloat2_t x)

move the "pen" to the point x without drawing a line

See also
begin_path()

◆ rect()

void BackendSVG::rect ( const bfloat2_t x,
float  r = 0.f 
)
noexcept

draw a rectangle, optionally with rounded corners

Parameters
xthe bounding box of the rectangle
rthe radius of the circle used to round the corners, default 0.f

◆ reset_transform()

void trase::BackendSVG::reset_transform ( )

resets the drawing transform to identity

See also
rotate(), translate()

◆ rounded_rect()

void BackendSVG::rounded_rect ( const bfloat2_t x,
float  r 
)
noexcept

draw a rectangle with rounded corners

Parameters
xthe bounding box of the rectangle
rthe radius of the circle used to round the corners

◆ stroke()

void BackendSVG::stroke ( )

finalise a drawing path with a drawn line along the path

See also
begin_path()

◆ text()

void BackendSVG::text ( const vfloat2_t x,
const char *  string,
const char *  end 
)

draws text to a given position

Parameters
xthe text position (see text_align())
stringa pointer to the text string
endpoints to the end of the string. Use nullptr to write entire string

◆ tooltip()

void BackendSVG::tooltip ( const vfloat2_t x,
const char *  string 
)

Set a tooltip.

This is used in prior to a call to rect() or circle(). Sets a tooltip text to display on mouseover on the rectangle or circle.

Parameters
xthe position of the tooltip
stringthe text of the tooltip

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