scenepic 1.1.0
3D Visualization Made Easy
Classes | Public Member Functions | Friends | List of all members
scenepic::Frame2D Class Reference

Represents a frame of a 2D animation. More...

#include <frame2d.h>

Public Member Functions

void add_line (const CoordinateBuffer &coordinates, const Color &line_color=Colors::Black, float line_width=1.0f, const Color &fill_color=Color::None(), bool close_path=false, const std::string &layer_id="")
 Add a line to the frame. More...
 
void add_rectangle (float x, float y, float w, float h, const Color &line_color=Colors::Black, float line_width=1.0f, const Color &fill_color=Color::None(), const std::string &layer_id="")
 Add a rectangle to the frame. More...
 
void add_circle (float x, float y, float radius, const Color &line_color=Colors::Black, float line_width=1.0f, const Color &fill_color=Color::None(), const std::string &layer_id="")
 Add a circle to the frame. More...
 
void add_image (const std::string &image_id, const std::string &position_type="fit", float x=0.0f, float y=0.0f, float scale=1.0f, bool smoothed=false, const std::string &layer_id="")
 Add an image to the frame. More...
 
void add_video (const std::string &position_type="fit", float x=0.0f, float y=0.0f, float scale=1.0f, bool smoothed=false, const std::string &layer_id="")
 Add a video to the frame. More...
 
void add_text (const std::string &text, float left, float bottom, const Color &color=Colors::White, float size_in_pixels=12.0f, const std::string &font_family="sans-serif", const std::string &layer_id="")
 Add some text to the frame. More...
 
std::uint16_t num_coordinates () const
 The number of coordinates in the buffer. More...
 
std::string to_string () const
 Return a JSON string representing the object. More...
 
JsonValue to_json () const
 Convert this object into ScenePic json. More...
 

Friends

class Canvas2D
 

Detailed Description

Represents a frame of a 2D animation.

Member Function Documentation

◆ add_circle()

void scenepic::Frame2D::add_circle ( float  x,
float  y,
float  radius,
const Color line_color = Colors::Black,
float  line_width = 1.0f,
const Color fill_color = Color::None(),
const std::string &  layer_id = "" 
)

Add a circle to the frame.

Parameters
xthe center x coordinate
ythe center y coordinate
radiusthe radius of the circle
line_colorthe color of the line
line_widththe width of the line
fill_colorthe fill color to use
layer_idthe unique ID of the layer for this primitive

◆ add_image()

void scenepic::Frame2D::add_image ( const std::string &  image_id,
const std::string &  position_type = "fit",
float  x = 0.0f,
float  y = 0.0f,
float  scale = 1.0f,
bool  smoothed = false,
const std::string &  layer_id = "" 
)

Add an image to the frame.

Parameters
image_idthe unique identifier of the image
position_typeone of "fit", "fill", "stretch", or "manual"
xx coordinate to draw image at if position_type == "manual".
yy coordinate to draw image at if position_type == "manual".
scalescale factor to draw image by if position_type == "manual".
smoothedwhether to draw an image with smoothing or using nearest neighbor.
layer_idthe unique ID of the layer for this primitive

◆ add_line()

void scenepic::Frame2D::add_line ( const CoordinateBuffer &  coordinates,
const Color line_color = Colors::Black,
float  line_width = 1.0f,
const Color fill_color = Color::None(),
bool  close_path = false,
const std::string &  layer_id = "" 
)

Add a line to the frame.

Parameters
coordinatesthe coordinates of the line
line_colorthe color of the line
line_widththe width of the line
fill_colorthe fill color to use
close_pathwhether to close the path
layer_idthe unique ID of the layer for this primitive

◆ add_rectangle()

void scenepic::Frame2D::add_rectangle ( float  x,
float  y,
float  w,
float  h,
const Color line_color = Colors::Black,
float  line_width = 1.0f,
const Color fill_color = Color::None(),
const std::string &  layer_id = "" 
)

Add a rectangle to the frame.

Parameters
xthe upper left corner x coordinate
ythe upper left corner y coordinate
wthe width of the rectangle
hthe height of the rectangle
line_colorthe color of the line
line_widththe width of the line
fill_colorthe fill color to use
layer_idthe unique ID of the layer for this primitive

◆ add_text()

void scenepic::Frame2D::add_text ( const std::string &  text,
float  left,
float  bottom,
const Color color = Colors::White,
float  size_in_pixels = 12.0f,
const std::string &  font_family = "sans-serif",
const std::string &  layer_id = "" 
)

Add some text to the frame.

Parameters
textthe text to display
leftthe pixel position of the left side of the text
bottomthe pixel position of the bottom of the text
colorthe color of the text
size_in_pixelsthe vertical size of the text in pixels
font_familythe font to use for the text
layer_idthe unique ID of the layer for this primitive

◆ add_video()

void scenepic::Frame2D::add_video ( const std::string &  position_type = "fit",
float  x = 0.0f,
float  y = 0.0f,
float  scale = 1.0f,
bool  smoothed = false,
const std::string &  layer_id = "" 
)

Add a video to the frame.

The image shown will be the corresponding frame from the video.

Parameters
position_typeone of "fit", "fill", "stretch", or "manual"
xx coordinate to draw the video frame at if position_type == "manual".
yy coordinate to draw the video frame at if position_type == "manual".
scalescale factor to draw the video frame by if position_type == "manual".
smoothedwhether to draw the video frame with smoothing or using nearest neighbor.
layer_idthe unique ID of the layer for this primitive

◆ num_coordinates()

std::uint16_t scenepic::Frame2D::num_coordinates ( ) const

The number of coordinates in the buffer.

◆ to_json()

JsonValue scenepic::Frame2D::to_json ( ) const

Convert this object into ScenePic json.

Returns
a json value

◆ to_string()

std::string scenepic::Frame2D::to_string ( ) const

Return a JSON string representing the object.

Friends And Related Function Documentation

◆ Canvas2D

friend class Canvas2D
friend

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