OpenShot Library | libopenshot  0.3.3
Point.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_POINT_H
14 #define OPENSHOT_POINT_H
15 
16 #include "Coordinate.h"
17 
18 #include "Json.h"
19 
20 namespace openshot
21 {
32 };
33 
41 enum HandleType {
42  AUTO,
44 };
45 
64 class Point {
65 public:
71 
73  Point();
74 
76  Point(float y);
77 
79  Point(float x, float y);
80 
82  Point(float x, float y, InterpolationType interpolation);
83 
85  Point(const Coordinate& co);
86 
89 
92 
95  void Initialize_Handles();
96 
98  void Initialize_LeftHandle(float x, float y);
99 
101  void Initialize_RightHandle(float x, float y);
102 
103  // Get and Set JSON methods
104  std::string Json() const;
105  Json::Value JsonValue() const;
106  void SetJson(const std::string value);
107  void SetJsonValue(const Json::Value root);
108 
109 };
110 
111 // Stream output operator for openshot::Point
112 template<class charT, class traits>
113 std::basic_ostream<charT, traits>&
114 operator<<(std::basic_ostream<charT, traits>& o, const openshot::Point& p) {
115  std::basic_ostringstream<charT, traits> s;
116  s.flags(o.flags());
117  s.imbue(o.getloc());
118  s.precision(o.precision());
119  s << "co" << p.co;
120  switch(p.interpolation) {
122  s << " LINEAR";
123  break;
125  s << " CONSTANT";
126  break;
128  s << " BEZIER[L" << p.handle_left << ",R" << p.handle_right << ']';
129  break;
130  }
131  return o << s.str();
132 }
133 
134 } // namespace openshot
135 
136 #endif
openshot::Point::Point
Point()
Default constructor (defaults to 1,0)
Definition: Point.cpp:20
openshot::Point::Initialize_LeftHandle
void Initialize_LeftHandle(float x, float y)
Set the left handle to a percent of the primary coordinate (0 to 1)
Definition: Point.cpp:52
openshot::Point::interpolation
InterpolationType interpolation
This is the interpolation mode.
Definition: Point.h:69
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::Point::co
Coordinate co
This is the primary coordinate.
Definition: Point.h:66
openshot::Point::handle_type
HandleType handle_type
This is the handle mode.
Definition: Point.h:70
openshot::HandleType
HandleType
When BEZIER interpolation is used, the point's left and right handles are used to influence the direc...
Definition: Point.h:41
Coordinate.h
Header file for Coordinate class.
openshot::AUTO
@ AUTO
Automatically adjust the handles to achieve the smoothest curve.
Definition: Point.h:42
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::Point::SetJsonValue
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition: Point.cpp:104
openshot::Point::Json
std::string Json() const
Generate JSON string of this object.
Definition: Point.cpp:63
openshot::LINEAR
@ LINEAR
Linear curves are angular, straight lines between two points.
Definition: Point.h:30
openshot::Point::SetJson
void SetJson(const std::string value)
Load JSON string into this object.
Definition: Point.cpp:87
openshot::Point::JsonValue
Json::Value JsonValue() const
Generate Json::Value for this object.
Definition: Point.cpp:70
openshot::Point::Initialize_RightHandle
void Initialize_RightHandle(float x, float y)
Set the right handle to a percent of the primary coordinate (0 to 1)
Definition: Point.cpp:57
openshot::Point::handle_left
Coordinate handle_left
This is the left handle coordinate (in percentages from 0 to 1)
Definition: Point.h:67
openshot::Point::Initialize_Handles
void Initialize_Handles()
Definition: Point.cpp:45
openshot::CONSTANT
@ CONSTANT
Constant curves jump from their previous position to a new one (with no interpolation).
Definition: Point.h:31
openshot::InterpolationType
InterpolationType
This controls how a Keyframe uses this point to interpolate between two points.
Definition: Point.h:28
openshot::Point::handle_right
Coordinate handle_right
This is the right handle coordinate (in percentages from 0 to 1)
Definition: Point.h:68
openshot::BEZIER
@ BEZIER
Bezier curves are quadratic curves, which create a smooth curve.
Definition: Point.h:29
Json.h
Header file for JSON class.
openshot::MANUAL
@ MANUAL
Do not automatically adjust handles (set them manually)
Definition: Point.h:43
openshot::Coordinate
A Cartesian coordinate (X, Y) used in the Keyframe animation system.
Definition: Coordinate.h:38
openshot::Point
A Point is the basic building block of a key-frame curve.
Definition: Point.h:64