scenepic 1.1.0
3D Visualization Made Easy
canvas2d.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#ifndef _SCENEPIC_CANVAS2D_H_
5#define _SCENEPIC_CANVAS2D_H_
6
7#include "color.h"
8#include "frame2d.h"
9#include "json_value.h"
10#include "layer_settings.h"
11
12#include <map>
13#include <memory>
14#include <string>
15#include <vector>
16
17namespace scenepic
18{
21 {
22 public:
24 const std::string& canvas_id() const;
25
32 std::shared_ptr<Frame2D> create_frame(const std::string& frame_id = "");
33
39
41 std::string to_string() const;
42
47
49 const Color& background_color() const;
50
53
55 double width() const;
56
58 double height() const;
59
64 const std::string& media_id() const;
65
80 const std::map<std::string, LayerSettings> layer_settings);
81
82 Canvas2D& media_id(const std::string& media_id);
83
84 private:
85 friend class Scene;
86
92 Canvas2D(const std::string& canvas_id, double width, double height);
93
94 std::string m_canvas_id;
95 std::string m_media_id;
96 std::vector<std::string> m_layer_ids;
97 std::map<std::string, LayerSettings> m_layer_settings;
98 std::map<std::string, std::uint8_t> m_layer_lookup;
99 std::vector<std::shared_ptr<Frame2D>> m_frames;
100 Color m_background_color;
101 double m_width;
102 double m_height;
103
104 // This will get out of sync with the above after a call to clear_script()
105 // DO NOT REMOVE - it is important
106 std::size_t m_num_frames;
107 };
108} // namespace scenepic
109
110#endif
A 2D canvas that can contain a number of Frame2Ds.
Definition: canvas2d.h:21
const std::string & canvas_id() const
A unique identifier for the canvas.
void clear_script()
Call this if you are dumping a ScenePic script in multiple parts, e.g.
Canvas2D & media_id(const std::string &media_id)
JsonValue to_json() const
Convert this object into ScenePic json.
const std::string & media_id() const
The unique ID of the media file associated with this canvas.
double width() const
The width of the canvas.
const Color & background_color() const
The background color of the frame.
std::string to_string() const
Return a JSON string representing the object.
std::shared_ptr< Frame2D > create_frame(const std::string &frame_id="")
Creates a new Frame2D object and appends to the list of Frame2Ds in the Canvas2D.
double height() const
The width of the canvas.
void set_layer_settings(const std::map< std::string, LayerSettings > layer_settings)
Specify the visibilities and opacities of certain mesh layers.
Canvas2D & background_color(const Color &color)
Set the background color of the frame.
Class for representing color values.
Definition: color.h:19
Representation of a JSON value according to the specification at https://www.json....
Definition: json_value.h:30
Top level container representing an entire ScenePic.
Definition: scene.h:58
Definition: audio_track.h:14