OpenShot Library | libopenshot 0.3.3
Loading...
Searching...
No Matches
Point.h
Go to the documentation of this file.
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
20namespace openshot
21{
33
45
64class Point {
65public:
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
112template<class charT, class traits>
113std::basic_ostream<charT, traits>&
114operator<<(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
Header file for Coordinate class.
Header file for JSON class.
A Cartesian coordinate (X, Y) used in the Keyframe animation system.
Definition Coordinate.h:38
A Point is the basic building block of a key-frame curve.
Definition Point.h:64
Coordinate handle_left
This is the left handle coordinate (in percentages from 0 to 1)
Definition Point.h:67
void SetJson(const std::string value)
Load JSON string into this object.
Definition Point.cpp:87
Json::Value JsonValue() const
Generate Json::Value for this object.
Definition Point.cpp:70
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
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
void Initialize_Handles()
Definition Point.cpp:45
HandleType handle_type
This is the handle mode.
Definition Point.h:70
Coordinate co
This is the primary coordinate.
Definition Point.h:66
InterpolationType interpolation
This is the interpolation mode.
Definition Point.h:69
Coordinate handle_right
This is the right handle coordinate (in percentages from 0 to 1)
Definition Point.h:68
Point()
Default constructor (defaults to 1,0)
Definition Point.cpp:20
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition Point.cpp:104
std::string Json() const
Generate JSON string of this object.
Definition Point.cpp:63
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29
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
HandleType
When BEZIER interpolation is used, the point's left and right handles are used to influence the direc...
Definition Point.h:41
@ AUTO
Automatically adjust the handles to achieve the smoothest curve.
Definition Point.h:42
@ MANUAL
Do not automatically adjust handles (set them manually)
Definition Point.h:43
InterpolationType
This controls how a Keyframe uses this point to interpolate between two points.
Definition Point.h:28
@ CONSTANT
Constant curves jump from their previous position to a new one (with no interpolation).
Definition Point.h:31
@ BEZIER
Bezier curves are quadratic curves, which create a smooth curve.
Definition Point.h:29
@ LINEAR
Linear curves are angular, straight lines between two points.
Definition Point.h:30