OpenShot Library | libopenshot  0.4.0
Coordinate.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_COORDINATE_H
14 #define OPENSHOT_COORDINATE_H
15 
16 #include <iostream>
17 #include "Fraction.h"
18 #include "Json.h"
19 
20 namespace openshot {
21 
38 class Coordinate {
39 public:
40  double X;
41  double Y;
42 
44  Coordinate();
45 
49  Coordinate(double x, double y);
50 
53  Coordinate(const std::pair<double, double>& co);
54 
55  // Get and Set JSON methods
56  std::string Json() const;
57  Json::Value JsonValue() const;
58  void SetJson(const std::string value);
59  void SetJsonValue(const Json::Value root);
60 };
61 
63 template<class charT, class traits>
64 std::basic_ostream<charT, traits>&
65 operator<<(std::basic_ostream<charT, traits>& o, const openshot::Coordinate& co) {
66  std::basic_ostringstream<charT, traits> s;
67  s.flags(o.flags());
68  s.imbue(o.getloc());
69  s.precision(o.precision());
70  s << "(" << co.X << ", " << co.Y << ")";
71  return o << s.str();
72 }
73 
74 }
75 
76 #endif
openshot::Coordinate::Y
double Y
The Y value of the coordinate (usually representing the value of the property being animated)
Definition: Coordinate.h:41
Fraction.h
Header file for Fraction class.
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::Coordinate::Coordinate
Coordinate()
The default constructor, which defaults to (0,0)
Definition: Coordinate.cpp:19
openshot::Coordinate::SetJsonValue
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition: Coordinate.cpp:70
openshot::Coordinate::SetJson
void SetJson(const std::string value)
Load JSON string into this object.
Definition: Coordinate.cpp:53
openshot::operator<<
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &o, const openshot::Coordinate &co)
Stream output operator for openshot::Coordinate.
Definition: Coordinate.h:65
openshot::Coordinate::Json
std::string Json() const
Generate JSON string of this object.
Definition: Coordinate.cpp:29
openshot::Coordinate::JsonValue
Json::Value JsonValue() const
Generate Json::Value for this object.
Definition: Coordinate.cpp:36
Json.h
Header file for JSON class.
openshot::Coordinate
A Cartesian coordinate (X, Y) used in the Keyframe animation system.
Definition: Coordinate.h:38
openshot::Coordinate::X
double X
The X value of the coordinate (usually representing the frame #)
Definition: Coordinate.h:40