Loading...
Searching...
No Matches
Point.h
Go to the documentation of this file.
// Copyright (c) 2008-2019 OpenShot Studios, LLC
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef OPENSHOT_POINT_H
#define OPENSHOT_POINT_H
#include "Coordinate.h"
#include "Json.h"
namespace openshot
{
enum InterpolationType {
BEZIER,
LINEAR,
CONSTANT
};
enum HandleType {
AUTO,
MANUAL
};
class Point {
public:
Coordinate co;
Coordinate handle_left;
Coordinate handle_right;
InterpolationType interpolation;
HandleType handle_type;
Point();
Point(float y);
Point(float x, float y);
Point(float x, float y, InterpolationType interpolation);
Point(const Coordinate& co);
Point(const Coordinate& co, InterpolationType interpolation);
Point(const Coordinate& co, InterpolationType interpolation, HandleType handle_type);
void Initialize_Handles();
void Initialize_LeftHandle(float x, float y);
void Initialize_RightHandle(float x, float y);
// Get and Set JSON methods
std::string Json() const;
Json::Value JsonValue() const;
void SetJson(const std::string value);
void SetJsonValue(const Json::Value root);
};
// Stream output operator for openshot::Point
template<class charT, class traits>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& o, const openshot::Point& p) {
std::basic_ostringstream<charT, traits> s;
s.flags(o.flags());
s.imbue(o.getloc());
s.precision(o.precision());
s << "co" << p.co;
switch(p.interpolation) {
case(InterpolationType::LINEAR):
s << " LINEAR";
break;
case(InterpolationType::CONSTANT):
s << " CONSTANT";
break;
case(InterpolationType::BEZIER):
s << " BEZIER[L" << p.handle_left << ",R" << p.handle_right << ']';
break;
}
return o << s.str();
}
} // namespace openshot
#endif
Coordinate.h
Header file for Coordinate class.
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::Point
A Point is the basic building block of a key-frame curve.
Definition Point.h:64
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::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::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::Initialize_Handles
void Initialize_Handles()
Definition Point.cpp:45
openshot::Point::handle_type
HandleType handle_type
This is the handle mode.
Definition Point.h:70
openshot::Point::co
Coordinate co
This is the primary coordinate.
Definition Point.h:66
openshot::Point::interpolation
InterpolationType interpolation
This is the interpolation mode.
Definition Point.h:69
openshot::Point::handle_right
Coordinate handle_right
This is the right handle coordinate (in percentages from 0 to 1).
Definition Point.h:68
openshot::Point::Point
Point()
Default constructor (defaults to 1,0).
Definition Point.cpp:20
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
This namespace is the default namespace for all code in the openshot library.
Definition Compressor.h:29
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::HandleType
HandleType
When BEZIER interpolation is used, the point's left and right handles are used to influence the direc...
Definition Point.h:41
openshot::AUTO
@ AUTO
Automatically adjust the handles to achieve the smoothest curve.
Definition Point.h:42
openshot::MANUAL
@ MANUAL
Do not automatically adjust handles (set them manually).
Definition Point.h:43
openshot::InterpolationType
InterpolationType
This controls how a Keyframe uses this point to interpolate between two points.
Definition Point.h:28
openshot::CONSTANT
@ CONSTANT
Constant curves jump from their previous position to a new one (with no interpolation).
Definition Point.h:31
openshot::BEZIER
@ BEZIER
Bezier curves are quadratic curves, which create a smooth curve.
Definition Point.h:29
openshot::LINEAR
@ LINEAR
Linear curves are angular, straight lines between two points.
Definition Point.h:30