OpenShot Library | libopenshot  0.7.0
AnimatedCurve.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2026 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_ANIMATED_CURVE_H
14 #define OPENSHOT_ANIMATED_CURVE_H
15 
16 #include "Json.h"
17 #include "KeyFrame.h"
18 #include "Point.h"
19 
20 #include <cstdint>
21 #include <string>
22 #include <vector>
23 
24 namespace openshot {
25 
27 public:
28  int id;
37 
39  AnimatedCurveNode(int node_id, double node_x, double node_y, InterpolationType node_interpolation=LINEAR);
40 
41  Point Evaluate(int64_t frame_number, double x_scale=1.0) const;
42 
43  std::string Json() const;
44  Json::Value JsonValue() const;
45  void SetJson(const std::string value);
46  void SetJsonValue(const Json::Value& root);
47 };
48 
50 private:
51  std::vector<AnimatedCurveNode> nodes;
52 
53 public:
55 
56  AnimatedCurve();
57 
58  const std::vector<AnimatedCurveNode>& Nodes() const { return nodes; }
59  std::vector<AnimatedCurveNode>& Nodes() { return nodes; }
60 
61  Keyframe BuildCurve(int64_t frame_number, double x_scale=1.0) const;
62  float Sample(float input, int64_t frame_number) const;
63  std::string Summary(int64_t frame_number) const;
64 
65  std::string Json() const;
66  Json::Value JsonValue() const;
67  void SetJson(const std::string value);
68  void SetJsonValue(const Json::Value& root);
69 };
70 
71 }
72 
73 #endif
openshot::AnimatedCurveNode::SetJson
void SetJson(const std::string value)
Definition: AnimatedCurve.cpp:74
openshot::AnimatedCurveNode::right_handle_x
Keyframe right_handle_x
Definition: AnimatedCurve.h:33
Point.h
Header file for Point class.
openshot::AnimatedCurveNode::x
Keyframe x
Definition: AnimatedCurve.h:29
openshot::AnimatedCurveNode::left_handle_y
Keyframe left_handle_y
Definition: AnimatedCurve.h:32
openshot::AnimatedCurve::Sample
float Sample(float input, int64_t frame_number) const
Definition: AnimatedCurve.cpp:128
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: AnimatedCurve.h:24
openshot::AnimatedCurve
Definition: AnimatedCurve.h:49
openshot::AnimatedCurve::BuildCurve
Keyframe BuildCurve(int64_t frame_number, double x_scale=1.0) const
Definition: AnimatedCurve.cpp:109
openshot::AnimatedCurveNode::right_handle_y
Keyframe right_handle_y
Definition: AnimatedCurve.h:34
openshot::AnimatedCurveNode::Evaluate
Point Evaluate(int64_t frame_number, double x_scale=1.0) const
Definition: AnimatedCurve.cpp:44
openshot::AnimatedCurveNode::JsonValue
Json::Value JsonValue() const
Definition: AnimatedCurve.cpp:60
openshot::AnimatedCurveNode::Json
std::string Json() const
Definition: AnimatedCurve.cpp:56
openshot::AnimatedCurve::enabled
Keyframe enabled
Definition: AnimatedCurve.h:54
openshot::AnimatedCurve::SetJsonValue
void SetJsonValue(const Json::Value &root)
Definition: AnimatedCurve.cpp:165
KeyFrame.h
Header file for the Keyframe class.
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::AnimatedCurve::Json
std::string Json() const
Definition: AnimatedCurve.cpp:144
openshot::AnimatedCurveNode::id
int id
Definition: AnimatedCurve.h:28
openshot::AnimatedCurve::AnimatedCurve
AnimatedCurve()
Definition: AnimatedCurve.cpp:103
openshot::AnimatedCurveNode::left_handle_x
Keyframe left_handle_x
Definition: AnimatedCurve.h:31
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:53
openshot::AnimatedCurve::Nodes
std::vector< AnimatedCurveNode > & Nodes()
Definition: AnimatedCurve.h:59
openshot::AnimatedCurve::JsonValue
Json::Value JsonValue() const
Definition: AnimatedCurve.cpp:148
openshot::LINEAR
@ LINEAR
Linear curves are angular, straight lines between two points.
Definition: Point.h:30
openshot::AnimatedCurve::Nodes
const std::vector< AnimatedCurveNode > & Nodes() const
Definition: AnimatedCurve.h:58
openshot::AnimatedCurveNode::y
Keyframe y
Definition: AnimatedCurve.h:30
openshot::AnimatedCurveNode::interpolation
InterpolationType interpolation
Definition: AnimatedCurve.h:35
openshot::AnimatedCurveNode::handle_type
HandleType handle_type
Definition: AnimatedCurve.h:36
openshot::InterpolationType
InterpolationType
This controls how a Keyframe uses this point to interpolate between two points.
Definition: Point.h:28
openshot::AnimatedCurve::Summary
std::string Summary(int64_t frame_number) const
Definition: AnimatedCurve.cpp:136
Json.h
Header file for JSON class.
openshot::AnimatedCurve::SetJson
void SetJson(const std::string value)
Definition: AnimatedCurve.cpp:157
openshot::AnimatedCurveNode
Definition: AnimatedCurve.h:26
openshot::AnimatedCurveNode::AnimatedCurveNode
AnimatedCurveNode()
Definition: AnimatedCurve.cpp:30
openshot::Point
A Point is the basic building block of a key-frame curve.
Definition: Point.h:64
openshot::AnimatedCurveNode::SetJsonValue
void SetJsonValue(const Json::Value &root)
Definition: AnimatedCurve.cpp:82