OpenShot Library | libopenshot  0.1.9
Color.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Header file for Color class
4  * @author Jonathan Thomas <jonathan@openshot.org>
5  *
6  * @section LICENSE
7  *
8  * Copyright (c) 2008-2014 OpenShot Studios, LLC
9  * <http://www.openshotstudios.com/>. This file is part of
10  * OpenShot Library (libopenshot), an open-source project dedicated to
11  * delivering high quality video editing and animation solutions to the
12  * world. For more information visit <http://www.openshot.org/>.
13  *
14  * OpenShot Library (libopenshot) is free software: you can redistribute it
15  * and/or modify it under the terms of the GNU Lesser General Public License
16  * as published by the Free Software Foundation, either version 3 of the
17  * License, or (at your option) any later version.
18  *
19  * OpenShot Library (libopenshot) is distributed in the hope that it will be
20  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26  */
27 
28 #ifndef OPENSHOT_COLOR_H
29 #define OPENSHOT_COLOR_H
30 
31 #include "KeyFrame.h"
32 #include <QtGui/QColor>
33 
34 namespace openshot {
35 
36  /**
37  * @brief This class represents a color (used on the timeline and clips)
38  *
39  * Colors are represented by 4 curves, representing red, green, blue, and alpha. The curves
40  * can be used to animate colors over time.
41  */
42  class Color{
43 
44  public:
45  Keyframe red; ///<Curve representing the red value (0 - 255)
46  Keyframe green; ///<Curve representing the green value (0 - 255)
47  Keyframe blue; ///<Curve representing the red value (0 - 255)
48  Keyframe alpha; ///<Curve representing the alpha value (0 - 255)
49 
50  /// Default constructor
51  Color() {};
52 
53  /// Constructor which takes a HEX color code
54  Color(string color_hex);
55 
56  /// Constructor which takes R,G,B,A
57  Color(unsigned char Red, unsigned char Green, unsigned char Blue, unsigned char Alpha);
58 
59  /// Constructor which takes 4 existing Keyframe curves
60  Color(Keyframe Red, Keyframe Green, Keyframe Blue, Keyframe Alpha);
61 
62  /// Get the HEX value of a color at a specific frame
63  string GetColorHex(int64_t frame_number);
64 
65  /// Get the distance between 2 RGB pairs. (0=identical colors, 10=very close colors, 760=very different colors)
66  static long GetDistance(long R1, long G1, long B1, long R2, long G2, long B2);
67 
68  /// Get and Set JSON methods
69  string Json(); ///< Generate JSON string of this object
70  Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
71  void SetJson(string value); ///< Load JSON string into this object
72  void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
73  };
74 
75 
76 }
77 
78 #endif
Json::Value JsonValue()
Generate Json::JsonValue for this object.
Definition: Color.cpp:92
Keyframe green
Curve representing the green value (0 - 255)
Definition: Color.h:46
Color()
Default constructor.
Definition: Color.h:51
Keyframe alpha
Curve representing the alpha value (0 - 255)
Definition: Color.h:48
Keyframe red
Curve representing the red value (0 - 255)
Definition: Color.h:45
string GetColorHex(int64_t frame_number)
Get the HEX value of a color at a specific frame.
Definition: Color.cpp:64
void SetJson(string value)
Load JSON string into this object.
Definition: Color.cpp:106
Header file for the Keyframe class.
static long GetDistance(long R1, long G1, long B1, long R2, long G2, long B2)
Get the distance between 2 RGB pairs. (0=identical colors, 10=very close colors, 760=very different c...
Definition: Color.cpp:75
Keyframe blue
Curve representing the red value (0 - 255)
Definition: Color.h:47
This class represents a color (used on the timeline and clips)
Definition: Color.h:42
This namespace is the default namespace for all code in the openshot library.
string Json()
Get and Set JSON methods.
Definition: Color.cpp:85
void SetJsonValue(Json::Value root)
Load Json::JsonValue into this object.
Definition: Color.cpp:129
A Keyframe is a collection of Point instances, which is used to vary a number or property over time...
Definition: KeyFrame.h:64