2012-11-29 23:11:50 -06:00
|
|
|
/**
|
2013-09-09 23:32:16 -05:00
|
|
|
* @file
|
|
|
|
|
* @brief Header file for Color class
|
2013-09-12 17:52:10 -05:00
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
2019-06-09 08:31:04 -04:00
|
|
|
* @ref License
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* LICENSE
|
2013-09-12 17:52:10 -05:00
|
|
|
*
|
2019-06-11 06:48:32 -04:00
|
|
|
* Copyright (c) 2008-2019 OpenShot Studios, LLC
|
2014-03-29 18:49:22 -05:00
|
|
|
* <http://www.openshotstudios.com/>. This file is part of
|
|
|
|
|
* OpenShot Library (libopenshot), an open-source project dedicated to
|
|
|
|
|
* delivering high quality video editing and animation solutions to the
|
|
|
|
|
* world. For more information visit <http://www.openshot.org/>.
|
2013-09-12 17:52:10 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
2014-07-11 16:52:14 -05:00
|
|
|
* and/or modify it under the terms of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* as published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
2013-09-12 17:52:10 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) is distributed in the hope that it will be
|
|
|
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-07-11 16:52:14 -05:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-09-12 17:52:10 -05:00
|
|
|
*
|
2014-07-11 16:52:14 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
2012-11-29 23:11:50 -06:00
|
|
|
*/
|
|
|
|
|
|
2013-09-12 17:52:10 -05:00
|
|
|
#ifndef OPENSHOT_COLOR_H
|
|
|
|
|
#define OPENSHOT_COLOR_H
|
|
|
|
|
|
2012-11-29 23:11:50 -06:00
|
|
|
#include "KeyFrame.h"
|
2015-02-17 00:21:57 -06:00
|
|
|
#include <QtGui/QColor>
|
2012-11-29 23:11:50 -06:00
|
|
|
|
|
|
|
|
namespace openshot {
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-01 00:20:14 -07:00
|
|
|
* @brief This class represents a color (used on the timeline and clips)
|
2012-11-29 23:11:50 -06:00
|
|
|
*
|
2015-06-01 00:20:14 -07:00
|
|
|
* Colors are represented by 4 curves, representing red, green, blue, and alpha. The curves
|
2012-11-29 23:11:50 -06:00
|
|
|
* can be used to animate colors over time.
|
|
|
|
|
*/
|
2015-06-01 00:20:14 -07:00
|
|
|
class Color{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Keyframe red; ///<Curve representing the red value (0 - 255)
|
|
|
|
|
Keyframe green; ///<Curve representing the green value (0 - 255)
|
|
|
|
|
Keyframe blue; ///<Curve representing the red value (0 - 255)
|
|
|
|
|
Keyframe alpha; ///<Curve representing the alpha value (0 - 255)
|
|
|
|
|
|
|
|
|
|
/// Default constructor
|
|
|
|
|
Color() {};
|
|
|
|
|
|
|
|
|
|
/// Constructor which takes a HEX color code
|
2019-08-04 22:48:57 -04:00
|
|
|
Color(std::string color_hex);
|
2015-06-01 00:20:14 -07:00
|
|
|
|
|
|
|
|
/// Constructor which takes R,G,B,A
|
|
|
|
|
Color(unsigned char Red, unsigned char Green, unsigned char Blue, unsigned char Alpha);
|
|
|
|
|
|
|
|
|
|
/// Constructor which takes 4 existing Keyframe curves
|
|
|
|
|
Color(Keyframe Red, Keyframe Green, Keyframe Blue, Keyframe Alpha);
|
2013-12-06 00:40:26 -06:00
|
|
|
|
2015-02-17 00:21:57 -06:00
|
|
|
/// Get the HEX value of a color at a specific frame
|
2019-08-04 22:48:57 -04:00
|
|
|
std::string GetColorHex(int64_t frame_number);
|
2015-02-17 00:21:57 -06:00
|
|
|
|
2015-06-01 00:20:14 -07:00
|
|
|
/// Get the distance between 2 RGB pairs. (0=identical colors, 10=very close colors, 760=very different colors)
|
|
|
|
|
static long GetDistance(long R1, long G1, long B1, long R2, long G2, long B2);
|
|
|
|
|
|
2013-12-06 00:40:26 -06:00
|
|
|
/// Get and Set JSON methods
|
2019-08-04 22:48:57 -04:00
|
|
|
std::string Json(); ///< Generate JSON string of this object
|
2013-12-06 00:40:26 -06:00
|
|
|
Json::Value JsonValue(); ///< Generate Json::JsonValue for this object
|
2019-08-04 22:48:57 -04:00
|
|
|
void SetJson(std::string value); ///< Load JSON string into this object
|
2013-12-07 21:09:55 -06:00
|
|
|
void SetJsonValue(Json::Value root); ///< Load Json::JsonValue into this object
|
2012-11-29 23:11:50 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|