OpenShot Library | libopenshot 0.2.7
Coordinate.h
Go to the documentation of this file.
1/**
2 * @file
3 * @brief Header file for Coordinate class
4 * @author Jonathan Thomas <jonathan@openshot.org>
5 *
6 * @ref License
7 */
8
9/* LICENSE
10 *
11 * Copyright (c) 2008-2019 OpenShot Studios, LLC
12 * <http://www.openshotstudios.com/>. This file is part of
13 * OpenShot Library (libopenshot), an open-source project dedicated to
14 * delivering high quality video editing and animation solutions to the
15 * world. For more information visit <http://www.openshot.org/>.
16 *
17 * OpenShot Library (libopenshot) is free software: you can redistribute it
18 * and/or modify it under the terms of the GNU Lesser General Public License
19 * as published by the Free Software Foundation, either version 3 of the
20 * License, or (at your option) any later version.
21 *
22 * OpenShot Library (libopenshot) is distributed in the hope that it will be
23 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public License
28 * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29 */
30
31#ifndef OPENSHOT_COORDINATE_H
32#define OPENSHOT_COORDINATE_H
33
34#include <iostream>
35#include "Fraction.h"
36#include "Json.h"
37
38namespace openshot {
39
40 /**
41 * @brief This class represents a Cartesian coordinate (X, Y) used in the Keyframe animation system.
42 *
43 * Animation involves the changing (i.e. interpolation) of numbers over time. A series of Coordinate
44 * objects allows us to plot a specific curve or line used during interpolation. In other words, it helps us
45 * control how a number changes over time (quickly or slowly).
46 *
47 * Please see the following <b>Example Code</b>:
48 * \code
49 * Coordinate c1(2,4);
50 * assert(c1.X == 2.0f);
51 * assert(c1.Y == 4.0f);
52 * \endcode
53 */
54 class Coordinate {
55 public:
56 double X; ///< The X value of the coordinate (usually representing the frame #)
57 double Y; ///< The Y value of the coordinate (usually representing the value of the property being animated)
58
59 /// The default constructor, which defaults to (0,0)
60 Coordinate();
61
62 /// @brief Constructor which also sets the X and Y
63 /// @param x The X coordinate (usually representing the frame #)
64 /// @param y The Y coordinate (usually representing the value of the property being animated)
65 Coordinate(double x, double y);
66
67 /// @brief Constructor which accepts a std::pair tuple for {X, Y}
68 /// @param co A std::pair<double, double> tuple containing (X, Y)
69 Coordinate(const std::pair<double, double>& co);
70
71 // Get and Set JSON methods
72 std::string Json() const; ///< Generate JSON string of this object
73 Json::Value JsonValue() const; ///< Generate Json::Value for this object
74 void SetJson(const std::string value); ///< Load JSON string into this object
75 void SetJsonValue(const Json::Value root); ///< Load Json::Value into this object
76 };
77
78}
79
80#endif
Header file for Fraction class.
Header file for JSON class.
This class represents a Cartesian coordinate (X, Y) used in the Keyframe animation system.
Definition: Coordinate.h:54
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition: Coordinate.cpp:88
Json::Value JsonValue() const
Generate Json::Value for this object.
Definition: Coordinate.cpp:54
std::string Json() const
Generate JSON string of this object.
Definition: Coordinate.cpp:47
void SetJson(const std::string value)
Load JSON string into this object.
Definition: Coordinate.cpp:71
double X
The X value of the coordinate (usually representing the frame #)
Definition: Coordinate.h:56
double Y
The Y value of the coordinate (usually representing the value of the property being animated)
Definition: Coordinate.h:57
Coordinate()
The default constructor, which defaults to (0,0)
Definition: Coordinate.cpp:37
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:47