OpenShot Library | libopenshot  0.2.5
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  * @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_COLOR_H
32 #define OPENSHOT_COLOR_H
33 
34 #include "KeyFrame.h"
35 #include <QtGui/QColor>
36 
37 namespace openshot {
38 
39  /**
40  * @brief This class represents a color (used on the timeline and clips)
41  *
42  * Colors are represented by 4 curves, representing red, green, blue, and alpha. The curves
43  * can be used to animate colors over time.
44  */
45  class Color{
46 
47  public:
48  openshot::Keyframe red; ///<Curve representing the red value (0 - 255)
49  openshot::Keyframe green; ///<Curve representing the green value (0 - 255)
50  openshot::Keyframe blue; ///<Curve representing the red value (0 - 255)
51  openshot::Keyframe alpha; ///<Curve representing the alpha value (0 - 255)
52 
53  /// Default constructor
54  Color() {};
55 
56  /// Constructor which takes a HEX color code
57  Color(std::string color_hex);
58 
59  /// Constructor which takes R,G,B,A
60  Color(unsigned char Red, unsigned char Green, unsigned char Blue, unsigned char Alpha);
61 
62  /// Constructor which takes 4 existing Keyframe curves
64 
65  /// Get the HEX value of a color at a specific frame
66  std::string GetColorHex(int64_t frame_number);
67 
68  /// Get the distance between 2 RGB pairs. (0=identical colors, 10=very close colors, 760=very different colors)
69  static long GetDistance(long R1, long G1, long B1, long R2, long G2, long B2);
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 
81 #endif
openshot::Color::Color
Color()
Default constructor.
Definition: Color.h:54
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: AudioBufferSource.h:39
openshot::Color::GetDistance
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:78
KeyFrame.h
Header file for the Keyframe class.
openshot::Color
This class represents a color (used on the timeline and clips)
Definition: Color.h:45
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:64
openshot::Color::SetJsonValue
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
Definition: Color.cpp:126
openshot::Color::green
openshot::Keyframe green
Curve representing the green value (0 - 255)
Definition: Color.h:49
openshot::Color::JsonValue
Json::Value JsonValue() const
Generate Json::Value for this object.
Definition: Color.cpp:95
openshot::Color::SetJson
void SetJson(const std::string value)
Load JSON string into this object.
Definition: Color.cpp:109
openshot::Color::alpha
openshot::Keyframe alpha
Curve representing the alpha value (0 - 255)
Definition: Color.h:51
openshot::Color::red
openshot::Keyframe red
Curve representing the red value (0 - 255)
Definition: Color.h:48
openshot::Color::GetColorHex
std::string GetColorHex(int64_t frame_number)
Get the HEX value of a color at a specific frame.
Definition: Color.cpp:67
openshot::Color::Json
std::string Json() const
Get and Set JSON methods.
Definition: Color.cpp:88
openshot::Color::blue
openshot::Keyframe blue
Curve representing the red value (0 - 255)
Definition: Color.h:50